EUpdateDialog (CJuiDialog) and AjaxSubmitButton

Hi All!

My question most probably is quite simple but as I don’t have much experience with Ajax, JQuery and Yii I can’t understand how it can be optimally achieved.

In my first Yii project I use extension EUpdateDialog which is based on CJuiDialog and allows to easily integrate such dialogs with controller actions.

I will attach the screenshot which I’m calling JUI dialog from.

[color=#FF0000]In red[/color] rectangle there is a link (Edit category) which initiates JUI dialog.

Menu links in the top are ajax, they allow to load action Admin of ProductCategory controller into <div> highlighted with [color=#0000FF]blue rectangle[/color].

I need to achieve the following behavior: when clicking on ‘Save’ in dialog I want to fully reload contents of this blue <div>. It’s not important for me that categories tree will get collapsed, more important that category changes will be applied to the page (as you can see category name in the tree right now doesn’t match the name in dialog even though it was saved).

As I understand this task should be solved with AjaxSubmitButton but I have no idea how to implement that and reload correct action in this <div>.

Next step will be to reload products grid after some of the products will be changed in the same manner but it is another long story…

Thanks to everyone for any input in advance!

Anyone? :rolleyes:

Which EUpdateDialog version are you using? Because the newest version has callbacks which are called after actions.

I believe what I indeed don’t understand doesn’t relate to Yii itself but more of JQuery nature.

My top menu allows me to load categories view with these simple lines of code:


array('label'=>Yii::t('menuItems','Products and Categories'), 

  'url'=>array('/productcategory/admin'),

  'visible'=>UserModule::isAdmin())

and


'ajax'=>array(

			      'update' => '#content',

			  )

But how can the same URL be formatted and transferred for loading in div using this callback JS function?

Thanks a lot in advance for any advise!

You can just simply write a function which will load the contents of the div from the url with a get or post request and then replace the contents. Actually the default view action already has a method implemented for reloading the content.

hi ifdattic,

thanks for your attention to this thread!

Sorry for my stupidity but could you please illustrate your words with some sample code because I’m totally lost how this interaction needs to be coded :(

And it would be great if you can tell me more about view method for reloading - may be it could help me as well.

Thank you a lot!

hi ifdattic,

I’ve managed to resolve even both my tasks separately: to reload the contents of <div> from ‘callback’ using JQuery.load() and to reload GridView contents using


$.fn.yiiGridView.update("product-grid");

Sorry, my question was indeed very stupid!

What I don’t understand now is how to join both these features on one page: I want to reload whole blue <div> if category was changed using dialog and I want to reload only GridView in case of some of it’s products are changed using dialog.

Could you advise if it is feasible to achieve these tasks on the same page?

Thanks a lot in advance!