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

Trigger a "tagRemoved" event to satisfy a use case where the "Save" butto #11

Closed
wants to merge 1 commit into from

Conversation

StevenBlack
Copy link
Contributor

Trigger a "tagRemoved" event to satisfy a use case where the "Save" button is disabled until the tags are actually modified. There is a transformToTag event which is very handy, but until now no event fires when a tag is removed.

Signed-off-by: Steven Black steveb@stevenblack.com

…utton is disabled until the tags are actually modified. There is a transformToTag event which is very handy, but until now no event fires when a tag is removed.

Signed-off-by: Steven Black <steveb@stevenblack.com>
@webworka
Copy link
Owner

webworka commented Jun 8, 2011

Thanks Steven,

I'll merge this tomorrow and maybe add some more events.
Great idea.

Oliver

@webworka
Copy link
Owner

Hi Steven,

I had a look on your changes. Maybe I did not get the point but how do you bind something on the event? You put the trigger on the autocompleter in case of backspace, on the list element in case of finishing the editing and clicking the cross.
So, if I wanted to bind something on that trigger, I can not do this from outside the plugin. right?

@StevenBlack
Copy link
Contributor Author

Assuming a jQuery-ui button,

    $tagSubmit.button( { icons: { primary: "ui-icon-check" }, disabled: true } );

    $( document ).bind( "transformToTag tagRemoved", function(){
        $tagSubmit.button( "enable" );
    });

We can bind to any parent container. Event bubbling takes care of the rest. Works like a charm!

@webworka
Copy link
Owner

My question was regarding the tagedit plugin. Not how to bind a even in general. How do you bin this even from the tagedit plugin?

@StevenBlack
Copy link
Contributor Author

You can bind to "#tagedit-input", no?

@webworka
Copy link
Owner

Yes. But this would in your case only work when pressing Backspace. When clicking the delete button (not in edit mode) the event will not fire because there "$(this)" is the li-Element.

Nevertheless I think it would be more comfortable binding the event on the tagedit Element or giving the with the options.

@StevenBlack
Copy link
Contributor Author

Sure, whatever works. I didn't have a use case for binding from within the plugin, just from a view manager outside the plugin.

What's your use case for needing it inside the plugin? Just wondering.

@StevenBlack
Copy link
Contributor Author

Hey so any more thoughts on this? I'm depending on tagRemoved now so maybe my instance is a diverged perma-fork?

@webworka
Copy link
Owner

Hi, sorry completly busy the last week. I'll answer in about an hour.

@webworka
Copy link
Owner

My idea on putting events on the plugin was to do something like this (like in jquery UI):

$('form input').tagedit();
$('form input').tagedit('newTagCreated', function() {alert('a new child was born')});

Where 'newTagCreated' ist the name of the event when the user adds an new tag.

In my opinion, binding an event to an element that is part of the plugin (i.e. "#tagedit-input") is not, lets say, comfortable enough.

@webworka
Copy link
Owner

webworka commented Nov 5, 2011

I close this one because binding of events should be done in a different way.
Thanks, anyway for your ideas on that.

@webworka webworka closed this Nov 5, 2011
@jamienk jamienk mentioned this pull request Jan 31, 2014
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

Successfully merging this pull request may close these issues.

3 participants