How to trigger Live() click in jquery?

The best solution would be to put your click handler in a separate function.

The best solution would be to put your click handler in a separate function. You can then call this function both from the live click handler and when you want to manually trigger the click.

You can call the function both in the live handler and elsewhere (including onComplete) – SLaks Jun 30 '10 at 14:40.

I guess the problem you're facing is, that live() and delegate() don't bind an event handler to the DOM element / jQuery object itself, but at some parent node. Live() for instance, will bind an handler to the document. Body which checks the event.target.In simple words, it makes usage of event bubbling, thats the idea of live events.

In other words, using live, it might be possible to trigger an event like $(document. Body). Trigger({ type: 'click', target: $('.

Text')0 }); update unfortunatly, that does not seem to work. I tried to also set the currentTarget and relatedTarget. Where does .live() bind an handler to?

Somebody?

As I was facing a similar situation, I found SLaks' solution perfectly helpful. However, attaching . Live("click", handlerFn) and .

Bind("click", handlerFn) to the same elements seems to be conflicting (I don't know what precedence rules apply in such a case). But it works fine if you use a custom event instead of "click" for the trigger. $(".

Elems"). Bind("customEvent", handlerFn); $(". Elems").

Live("click", handlerFn); $(". Elems"). Trigger("customEvent"); function handlerFn() { }.

I had the same problem when using Lightbox2 which binds the click event using live(). In my case the solution was to trigger the event like this: jQuery**('arel^="lightbox"')**. Ready(function () { jQuery("#myimglink").

Trigger("click"); }) As you can see I was triggering the event only after all the images that are using lightbox are ready. Hope it will help you all - this being my first contribution to stackoverflow :).

I belive you can just use your first example as trigger is only used to activate a bound element, not to bind it.. So when your do: $('#someElement'). Live('click',function(){. /*..*/}); this is the same as $('#someElement').

Click(function(){. /*..*/}); apart from the first one also checks for new html on every ajax requests and binds again. So just do: $('div.

Class'). Trigger('click'); and it should trigger the live elements.

1 Wrong. Live is very different from bind. You're confusing it with livequery, which does work like that.

– SLaks Jun 30 '10 at 13:53 yes I understand that live is different but once the ajax content as come back and injected into the DOM, live takes into place and binds the elements before the task is copmpleted, once inside the dom and bound to the click, trigger should also work for the "new content" – RobertPitt Jun 30 '10 at 13:57 2 You're wrong. Live does not bind any elements. Calling live will handle the event on the root element, which will see every event that bubbles up.It then checks e.

Target and raises any handlers that subscribed to that target. – SLaks Jun 30 '10 at 13:58 @SLaks is correct, .live() doesn't do any work when AJAX events happen, the DOM gets modified, etc.It's a passive listener, waiting for events to bubble. – Nick Craver?

Jun 30 '10 at 14:01 1 Ok then my apologise for that, ill have to read up about the way live works in more detail. Thanks for that. – RobertPitt Jun 30 '10 at 14:04.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions