When one adds content asynchronously, those elements may not have had
any event handlers registered. So, when clicked, the expected behavior
does not occur. You'll need to use a callback that deals with
registering any handlers on the newly-added elements. That'd usually
be in the "success" callback of your ajax load function.

If you're using Cake's AjaxHelper, the following won't be directly
relevant (it doesn't use jquery) but may explain the issue better:

http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_AJAX_request.3F

On Sat, Apr 18, 2009 at 7:49 PM, adallas <[email protected]> wrote:
>
> I have code that invokes an Ajax action in the controller that renders
> a specific view into a <div>. The view includes an $ajax->link that
> invokes a different Ajax action. The 2nd action renders a different
> view into the same <div>. These two switch back and forth.
>
> When I add a $javascript->codeBlock('alert("huh?");'); call to the
> view, not only don't I see an alert, but the Ajax functionality stops
> working, as well. In Firebug, I see no Javascript code in the Ajax-
> updated <div>. However, looking at $this->output in the controller
> just after the $this->render code, I see it.
>
> I can guess only two possibilities. 1) the controller renders the view
> but then filters out the Javascript code for some reason as it builds
> the Ajax response (I use the 'ajax' parameter to the render call, by
> the way). Or, 2) The Ajax Javascript in the <div> conflicts somehow
> with the other Javascript and Firebug is lying to me.
>
> I'm inclined toward explanation #1, but it's odd that $this->output is
> unfiltered. The render call specified 'ajax'--if you want to filter
> Javascript in the case of Ajax, I would think render would do it when
> you utter 'ajax'. And why did the Ajax link stop working?
>
> Does this sound familiar to anyone?
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to