Display Javascript In Ajax Update

hi

i use ajaxlink and ajaxsubmit buttonfor show products list and their comments.

whene updated the content any javascript content removed and i cant send another ajax request.

i found its the ajax problem but in php has solution to use "eval()" function but i dont know how its solve in yii.

its the ajax submit bottun problem too and if you add any javascript script to content that will be update its removed.

any one can help me?

im confused

Hi rahana, welcome to the forum.

Well, I’m not sure if it will help you or not, but personally I believe that it’s better not to include JS in the ajax responses. Just return only plain HTML or json as an ajax response … it means that you have to send all the JS code in the initial loading of the page. You may not like this idea, but it will enable you to manage your code much easier.

Please take a look at this thread also:

http://www.yiiframework.com/forum/index.php/topic/52188-using-widgets-on-views-loaded-by-ajax

thank for your reply.

i want to not use ajax but my program is like facebook that in every update new posts shown and users can left comment ajaxy.

now i cant tell users you can leave post only for some first posts.

i think its the ajax bug.

I didn’t say that we should not use ajax.

You should be able to write your ajax function for user comments without including JS in the response.

Pragmatically speaking, you’d better not put CHtml::ajaxSomething in the area which will be updated by ajax. In other words, do not use them in a CGridView row or in a CListView partial view. Instead, you can write a JS code manually to handle the event using jQuery.on() outside the CGridView or CListView.

you say right. its not good but i have no way, must write manualy that.

thank softark.