Create new DIV


Maybe somebody know how create new <div> in DOM and send there some $content with variables (AJAX)? I can do this in JQuery, but perhaps is possible do this in Yii only?

Regards Przemek.

What specifically are you trying to do? There is no way to manipulate the DOM without using some kind of Javascript.

Here is one of many examples of how to use jQuery inside of Yii Creating a dependent drowdown

OK this is scenario:

  1. click on link (or DOM object);

  2. get variable from link

  3. create new DIV (JQuery + widget? )

  4. load view into created DIV with variables

Something like ‘View topic preview’ in this forum

You’ll need to create javascript code to manipulate DOM manually. The only useful Yii class here is CClientScript (see registerScript and registerScriptFile).

Updating div content can be done using CHtml.ajaxLink() (see CHtml.ajax() update and replace options). Also I think you can put a creation of div into ajax beforeSend option.

As mentioned above by Angelo, dependent dropdown is a nice example. The only difference is you’ll need to update a div instead of dropdown list.