EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on December 05, 2014, 04:50:34 AM



Title: pre-process an event [Solved]
Post by: devnull on December 05, 2014, 04:50:34 AM
Is it possible to process all events for an object and then allow subsequent occurrences to also process the event afterwards:

Code:
$.extend($.fn.tabs.defaults, {
  onSelect: function(title){
    ...do something for all events
  }
})

$('#mytab').tabs({
  onSelect: function(){
   ...do something just for this event
  }
})

so that "...do something for all events" is always processed first for all tabs even if they have a onSelect() function ?


Title: Re: pre-process an event
Post by: stworthy on December 05, 2014, 07:03:54 AM
Please try this:
Code:
$('#mytab').tabs({
onSelect:function(title){
$.fn.tabs.defaults.onSelect.call(this, title);
console.log('do something just for this event');
}
})


Title: Re: pre-process an event
Post by: devnull on December 05, 2014, 05:56:32 PM
Thanks so much, but I am trying to do it the other way around so that I do not have to change all of the existing pages which already use the tabs.onChange() event.

Is it possible to extend the tabs so that it performs the pre-process before calling the onChange() without having to modify all of the other pages that make use of the onChange event ?

I guess what I am really looking for is an onBeforeSelect() type event.


Title: Re: pre-process an event
Post by: stworthy on December 06, 2014, 05:57:49 AM
The 'onBeforeOpen' event of panel fires before the 'onSelect' event of tabs. It can be used to perform your pre-processing before selecting a tab panel.
Code:
var mytab = $('#mytab').tabs({...});  // create the tabs component
$.each(mytab.tabs('tabs'), function(index,p){
p.panel('options').onBeforeOpen = function(){
console.log('do something before selecting the panel');
}
});