EasyUI Forum
May 17, 2024, 06:11:59 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: loading easyui with ajax [Solved]  (Read 7856 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« 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 ?



« Last Edit: May 21, 2014, 04:52:17 PM by devnull » Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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.
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #2 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.
Logged

-- Licensed User --
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!