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

onBeforeTagRemove async #59

Closed
webchaz opened this issue Jun 30, 2016 · 10 comments
Closed

onBeforeTagRemove async #59

webchaz opened this issue Jun 30, 2016 · 10 comments

Comments

@webchaz
Copy link

webchaz commented Jun 30, 2016

Using confirm works with this method to return true or false because it's synchronous. However, trying to return true or false asynchronously doesn't work.

For example:

onBeforeTagRemove: function(event, tag) {
   customAsyncAlertMethod(function(response) {
       if (response) return true;
       return false;
    });
});

This won't work. Is there another way to get around this? Thank you

@okcoker
Copy link
Owner

okcoker commented Jun 30, 2016

Hmm... currently no but that would definitely be useful. I could see the implementation working something like the below maybe:

onBeforeTagRemove: function(event, tag, callback) {
   customAsyncAlertMethod(function(response) {
       callback(!response);
    });
});

Thoughts?

@webchaz
Copy link
Author

webchaz commented Jun 30, 2016

Definitely, that would be perfect.

@webchaz
Copy link
Author

webchaz commented Jul 6, 2016

@okcoker Do you think this is something you'd be able to implement? So far, taggle's been great by the way!

@okcoker
Copy link
Owner

okcoker commented Jul 7, 2016

Yea, sorry just have been really busy. Will get on this ASAP. I do agree its an important feature.

@webchaz
Copy link
Author

webchaz commented Jul 27, 2016

No problem! Figured I'd just check in to see if you think you'll have time to add this.

@okcoker okcoker closed this as completed in 55b0345 Aug 2, 2016
@okcoker
Copy link
Owner

okcoker commented Aug 2, 2016

Hey @webchaz made the callback more node style so you just call the callback with no arguments to pass, or with any truthy value if there was an error.

Updated the example above for how this would work

@webchaz
Copy link
Author

webchaz commented Aug 3, 2016

This is great! Would you be able to add the same to the onBeforeTagAdd event also?

@okcoker
Copy link
Owner

okcoker commented Aug 3, 2016

That's partly why this took a while. I'd like the API to be consistent in that way but adding to onBeforeTagAdd would require a bit more reworking.

@webchaz
Copy link
Author

webchaz commented Aug 3, 2016

Ah ok, maybe I can take a look and see if I can put in an update for it - This is the last piece of the puzzle :). Looks like the new changes aren't in npm though?

@okcoker
Copy link
Owner

okcoker commented Aug 3, 2016

Wanted to wait for the remaining issues, but if you wanna look into implementing onBeforeTagAdd feel free :)

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