EasyUI Forum
April 19, 2024, 03:00:30 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: determining object type  (Read 20334 times)
Onegin
Newbie
*
Posts: 11


View Profile
« on: July 07, 2011, 11:39:44 AM »

Is it possible to determine what UI object is attached to a DOM node?
e.g.

$('#tt').datagrid({config...})

how can I check that UI object attached to $('#tt') is actually datagrid? Option object does not return it.
I use to reload data in grids using single common function, but have troubles to determine if it is datagrid or treegrid.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 07, 2011, 06:50:29 PM »

The all plugin such as datagrid and treegrid is same as other jQuery plugins(find, html, val, etc), they all extend with jQuery.fn object.
There is no efficient way to determine the object type, but you can add a type option while creating your object and then read this type from the 'options' object or directly to determine its object like this:

Code:
var target = $('#tt').get(0); // the DOM object
if ($.data(target,'treegrid')){
  alert('treegrid');
} else if ($.data(target,'datagrid')){
  alert('datagrid')
}
Logged
Onegin
Newbie
*
Posts: 11


View Profile
« Reply #2 on: July 08, 2011, 01:08:23 AM »

Thank you. Worked. Roll Eyes
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!