EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: kudoof on August 14, 2013, 08:01:04 AM



Title: Accordion: change title text on Collapse and
Post by: kudoof on August 14, 2013, 08:01:04 AM
Searched but did not find similar questions.   I found onCollapse event listed in the Panel events so I assume it is inherited in Accordion.  However I tried the following with no luck:

Code:
$('#spouse_info').accordion({
border: false,
onCollapse: function(title){
$('#spouse_info').accordion('setTitle',"Click to expand");
}
});



Title: Re: Accordion: change title text on Collapse and
Post by: stworthy on August 14, 2013, 06:49:55 PM
The 'onCollapse' is one of panel events. It need to be applied on the panel component. Call 'getPanel' method of accordion to get a panel and attach the 'onCollapse' event to it.

Code:
var p = $('#aa').accordion('getPanel',1);  // get the second panel
var opts = p.panel('options');
var onCollapse = opts.onCollapse;
opts.onCollapse = function(){
$(this).panel('setTitle', 'Click to expand');
onCollapse.call(this);
}


Title: Re: Accordion: change title text on Collapse and
Post by: kudoof on August 14, 2013, 11:11:00 PM
Worked!  Also added onExpand the same way.  Thanks a lot!

Another question here: how to set one panel to be uncollapsible, either at initialization or the user wants to 'anchor' it