EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: mzeddd on October 05, 2015, 03:35:23 AM



Title: Why $(this).<plugin> sometimes does not work inside event calls.
Post by: mzeddd on October 05, 2015, 03:35:23 AM
I just want to continue this topic: http://www.jeasyui.com/forum/index.php?topic=5275.0

This example works fine
Code:
$('#test').combotree({
multiple: true,
onlyLeafCheck:true,
onLoadSuccess: function(node,data){
var values = $('#test').combotree('getValues');
alert(JSON.stringify(values));
}
});

But if I change
Code:
$('#test').combotree('getValues')
to
Code:
$(this).combotree('getValues')
I get error:

Quote
TypeError: $.data(...) is undefined .... jquery.easyui.min.js:12401:9 (for 1.4.3)

At the same time if I change this line to
Code:
$(this).tree('getChecked')
or
$(this).tree('getSelected')
then it works, but works only in case if elements are loaded. In case if element is still selected after 'reload' call but not loaded I get [] what is wrong.


Title: Re: Why $(this).<plugin> sometimes does not work inside event calls.
Post by: mzeddd on October 06, 2015, 04:21:24 AM
And the question is:
How I can redefine "onLoadSuccess" and other events in $.fn.combotree.defaults and use "getValues"-like functions via this and get access to all features I usually have when I know #object id?

I would like to have the same business logic for all combotree with only one place where it could be changed.