EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on May 21, 2014, 05:38:41 AM



Title: loading easyui with ajax [Solved]
Post by: devnull on May 21, 2014, 05:38:41 AM
In my application, I have a static menu tree on the left, and a "content" panel on the right.

The content panel is loaded using ajax & $('#content).html(data); , the problem with this is that the easyui objects which are loaded are not initiated and so I have to run the $.parser.parse("#content) to initialize the elements.

The problem is if some of the objects have events defined via javascript, the elements get initialized twice and if they have a url set, then the object will make 2 ajax calls.

Is it possible to modify the parser so that it ONLY initializes objects that have not already been initialized, rather than initializing everything ?





Title: Re: loading easyui with ajax
Post by: stworthy on May 21, 2014, 06:39:35 AM
If you are using 'html()' to update a panel's content, the easyui objects can not been created. To solve this issue, please use the panel's 'refresh' method instead.
Code:
$('#content').panel('refresh', 'content.html');
As the code above shows, the 'content.html' page will be loaded into '#content' panel, all the easyui objects will be created when loaded successfully.


Title: Re: loading easyui with ajax
Post by: devnull on May 21, 2014, 04:51:55 PM
Thanks, I switched to using the panel & href method rather than using $.html() and the problem is solved.