vitalets / x-editable

In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
http://vitalets.github.io/x-editable
MIT License
6.51k stars 1.72k forks source link

Shown() event not fired for delegated targets #284

Open Arshad1024 opened 11 years ago

Arshad1024 commented 11 years ago

Hi, first of all thanks a lot for a great plugin. Really helpful. I've just come across a situation where i need to run a function whenever the dialog and form is shown. The shown() event works great but while working with delegated targets, the shown event doesn't seems to work for elements added on the fly. I tried adding the shown() event to the fiddle you already had on your site http://jsfiddle.net/xBB5x/1515/ Am i doing it the wrong way? If not is there any fix for this?

vitalets commented 11 years ago

hi, @cr4ken ! You are doing everything right, it's the feature that I totally foggoten. It was already mentioned in #86 to use trigger instead of triggerHandler to let event be propagated up to parent element. I will do it in next release and update this issue. Currently not possible (

Arshad1024 commented 11 years ago

Never mind thanks for clarification :) cheers

LostCrew commented 11 years ago

hi @vitalets ,

i'd love have this implemented, both for shown and hidden events. would you like some help developing it?

vitalets commented 11 years ago

hi @LostCrew l'm a bit overloaded now but pull request are always appreciated ) Exactly for that issue the pitfall is that shown / hidden event names can be used by other widgets (e.g. bootstrap popover) and we can get weird behavior..

cigaar commented 11 years ago

+1

tmorehouse commented 10 years ago

Any chance of using custom event namespaces or custom event names?

chall8908 commented 10 years ago

+1 for event namespaces, would help a lot in instances where event name collisions occur (such as the aforementioned shown).

tmorehouse commented 10 years ago

Bootstrap (V3 at least, not familiar that much with V2) shown is namespaced, so its easy to filter the bootstrap only events. So for targeting bootstrap's events the event's wont collide (if you use the full event name for the modals), but select2 will get hit twice on shown potentially. I've been tempted to edit a local copy for my use and replace the triggerHandler('shown') statements with trigger('x-editable.shown'), and find any local listeners to use the namespaced version.

jerimiahmilton commented 10 years ago

This would be a great benefit to have! I will take a look into implementing this myself.

valieand commented 10 years ago

any progress on this? I deadly need $('body').on('save', '#editable', function(){...}) as I'm developing dynamically updated page. Thanks

Arshad1024 commented 10 years ago

@valieand you can replace triggerHandler with trigger in js, that works.

valieand commented 10 years ago

@cr4ken - thanks a lot! it works!

sdishman commented 7 years ago

I've just run up against this bug, and it's preventing me from doing something pretty important for my use case. I know it's been awhile since this was opened, but I figured I would check in and see if there's any update on this issue?

gordol commented 7 years ago

@sdishman

https://github.com/vitalets/x-editable/issues/86