EasyUI Forum
May 16, 2024, 04:12:53 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: How to detect the type of easyui object, from its id id?  (Read 4376 times)
Don_Juan
Newbie
*
Posts: 20


View Profile
« on: July 07, 2017, 07:24:41 AM »

Hello to all,
I have a curiosity to which I did not find an answer. Huh
Can I detect the type of an object from its name?

Example:

I have an element called myElement.
Object type combobox.
$ ('# myElement') combobox ();

Now, if I have the name (myElement), How do you find that the easyui object type is a combobox?
I hope I have described my curiosity well.
Thank you all  Grin
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: July 07, 2017, 06:30:54 PM »

Please call this function to get the object type.
Code:
function getType(target){
var plugins = $.parser.plugins;
for(var i=plugins.length-1; i>=0; i--){
if ($(target).data(plugins[i])){
return plugins[i];
}
}
return null;
}
Logged
Don_Juan
Newbie
*
Posts: 20


View Profile
« Reply #2 on: July 10, 2017, 12:41:49 AM »

Thank you so much for answering my question.

Var plugins, is an array that contains all type objects; With loop for, check if my target matches one of those in the array plugins.
It is not very clear though what makes $ (target) .data (plugins ).

I insert a control into loop for:

Code:
	for(var i=plugins.length-1; i>=0; i--){
            var ctrl = $(target).data(plugins[i]);
            console.log(i + " TARGET " + target + " is PLUGIN " + plugins[i] + "? " + ctrl);
            if (ctrl){
                return plugins[i];
            }
}

The answer to each call is indefinite, except in the right case, which returns [object, Object]

Thanks
« Last Edit: July 10, 2017, 12:49:21 AM by Don_Juan » 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!