EasyUI Forum
May 15, 2024, 06:11:23 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: can i bind event to component after markup init ?  (Read 9056 times)
yulei
Newbie
*
Posts: 9


View Profile Email
« on: April 19, 2015, 06:15:14 PM »

I like the markup style very much,component can be declare by html with less javascript.
the html is readable , the javscript block is clear.

but, i have an obsession for javacirpt in html : I don't want any javascript code in the html markup.
the best style I want  is like this:
the html code:
Code:
<div id='the_id'  data-options= 'only options here ' class='esayui-component-name'
then the javascript code:
Code:
   $('#the_id').component-name('bind','eventName',function(){
         event handler...
   })
is it possible without javascirpt code init but can bind event after component  init ready?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: April 19, 2015, 11:17:51 PM »

You can declare all the properties on the markup and then create this component using javascript. When creating a component using javascript, you can add any other properties and events, please remember to remove the "easyui-*" class from the markup.

The code below declare some properties on the <input> element except the 'easyui-textbox' class.
Code:
<input id="tb" style="width:200px" data-options="
    prompt: 'Input something here...',
    required: true">

You can create the textbox component using javascript.
Code:
$(function(){
  $('#tb').textbox({
    onChange: function(value){...}
  });
});
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!