Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing back error messages? #14

Open
testbird opened this issue Feb 10, 2014 · 1 comment
Open

passing back error messages? #14

testbird opened this issue Feb 10, 2014 · 1 comment

Comments

@testbird
Copy link

The example in the readme simply calls insert from a success callback.

Could you add to the example how to wire up validation and insert errors, for example those returned from collection2 inserts or updates, so that they are shown with the x-editable UI, if that is possible?

@zimme
Copy link

zimme commented Mar 12, 2014

This is the code i use for the url key to get validation to work

updateName = (options) ->
    d = new $.Deferred
    Users.update options.pk, $set:
        'profile.name': options.value
    , (err) ->
        if err
            d.reject err
        else
            d.resolve options.pk
    d.promise()

Template.listUsersItem.rendered = ->
    options =
        display: false
        error: (error) ->
            error.reason
        pk: @data._id
        success: (pk) ->
                console.log "Do something with #{pk}"
        type: 'text'
        url: updateName

    dom = $(@findAll('a[data-name="name"]'))
    dom.editable options

It returns a promise and rejects it with the error message from a failed update/insert
or resolves with the primary key but you could resolve it with something else
that suits you needs.

I set display: false to let meteor reactively update the content instead of letting xeditable do it

Also worth mentioning is that I'm using Blaze-rc0 branch so I don't know how this will work when using spark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants