EasyUI Forum
September 13, 2025, 06:12:50 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Load easyui-window markup only when needed  (Read 11114 times)
snowsnow
Newbie
*
Posts: 6


View Profile
« on: November 24, 2014, 11:40:46 AM »

I have a easyui-window with lots of content. However, the window is rarely needed in my application.
Because of that I would like to load the code <div class=easyui-window>(lots of stuff here)</div> not on page load, but only when the user needs it.
How is this best done with easyui? Thanks!  Smiley Smiley
Logged
jarry
Administrator
Hero Member
*****
Posts: 2298


View Profile Email
« Reply #1 on: November 24, 2014, 04:49:44 PM »

Create a closed window and set 'href' property to indicate what content page will be loaded. This content page does not been loaded until the window is opened.
Code:
<div id="w" class="easyui-window" title="Basic Window" closed="true" href="content.html" style="width:500px;height:200px;padding:10px;">
</div>
Logged
snowsnow
Newbie
*
Posts: 6


View Profile
« Reply #2 on: November 25, 2014, 03:42:10 AM »

Thanks!!
The html nodes that make up the window are added to the DOM after page load ... so I guess I have to observe events (e. g. 'click') inside the <window> with jQuery's delegate function .on().

Does easyui offer a solution for that? That'd be great.




Logged
jarry
Administrator
Hero Member
*****
Posts: 2298


View Profile Email
« Reply #3 on: November 25, 2014, 08:21:56 AM »

Why do you want to listen for the click event on window? If so please try this.
Code:
$(function(){
$(document).on('click','.window',function(e){
console.log('click')
})
})
Logged
snowsnow
Newbie
*
Posts: 6


View Profile
« Reply #4 on: November 25, 2014, 09:36:35 AM »

Thanks for the sample code, that's exactly how I do it. I thought there was some easyui specific way of doing this, that is why I asked.

My window contains several buttons the user can click to perform certain tasks, that is why I need a event listener for the window.

Logged
jarry
Administrator
Hero Member
*****
Posts: 2298


View Profile Email
« Reply #5 on: November 25, 2014, 03:16:55 PM »

The linkbutton has the built-in 'onClick' event. You can use it to perform the clicking action.
Logged
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!