ajax links not working after rendering inside another view via ajax

i have and ajax button, when clicked on it, it sends an ajax request to a another controller’s function which renders a view and sends the data back to the request. after successful request a div is updated with the data.

the issue is that the sent data (rendered view) also has ajax buttons to perform some actions, but the action script related to them is not sent along with the data.

i m using render partial to render the view.

is there any way to send the script of those ajax buttons too or any way to register them?

i found the issue was renderPartial fucntion’s last two parameters

now is used it like this




$this->renderPartial('ajaxView',array(

			'dataProvider'=>$dataProvider,

		),false,true);



but it registers the jquery too. is it ok or will the jquery affect any other thing on the page ( like if jquery is already included on the page), if so then how to skip the jquery registration again?

Maybe you can try to register a script in rendered view. I think it will work. Can you show us the rendered code?

Reloading jquery can make some problems… there are many threads about this already in the forum…

You have 2 possibilities…

1 - put all jquery code in the first view, the second view loads just pure HTML

2 - do not load jquery on every request (note that there can be more files, not only jquery - you need to prevent all of them from re-loading)

These wiki can give you some ideas:

http://www.yiiframework.com/wiki/236/avoiding-duplicate-script-download-when-using-ajax-calls-to-render-different-views/

http://www.yiiframework.com/wiki/231/avoiding-duplicate-script-download-when-using-cactiveform-on-ajax-calls/