Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Mirel Galán on Oct 28, 2008 11:46
open dhtmlx forum
How avoid that a item in a accordion component opens

How avoid that the onActive event opens the selected item.

I have this code:

...
dhxAccord.attachEvent("onActive", onActive);
...

function onActive(itemId) {
if(itemId=="something")
return false;
}

But this not works!

Thx
Answer posted by Support on Oct 29, 2008 09:42
Modify your dhtmlxaccordion.js file like this:

find:
this.addItem = function(itemId, itemText) {
    ....
    label.onclick = function() { that.openItem(this._idd, "dhx_accord_outer_event"); }
    ...
}

and replace with:
this.addItem = function(itemId, itemText) {
     ...
     label.onclick = function() {
         if (that.checkEvent("onBeforeActive")) {
             if (that.callEvent("onBeforeActive", [this._idd])) {
                 that.openItem(this._idd, "dhx_accord_outer_event");
             }
         } else {
             that.openItem(this._idd, "dhx_accord_outer_event");
         }
     }
     ...
}

then in main code add after init:
dhxAccord.attachEvent("onBeforeActive", function(id){
    return true; // allow event
    return false; // or without any return - deny event
});