Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

I have a problem with jquery ui. I need to close a certain accordion panel when a user clicks a button. I have searched for the answer but can't get it to work. Any help would be much appreciated.

C#
$(function () {
            $("#accordion").accordion({
                heightStyle: "content",
                active: false,
                collapsible: true,
                },
                beforeActivate: function (event, ui) {
                    var page_id;
                    if (ui.newHeader.attr("id") == "" || ui.newHeader.attr("id") == null) {
                        page_id = ui.oldHeader.attr("id");
                    }
                    else {
                        page_id = ui.newHeader.attr("id");
                    }
                    var page_image_arr = document.getElementById("img_acc_" + page_id).src.split('/');
                    if (page_image_arr[page_image_arr.length - 1] == "yes.png" && page_image_arr[page_image_arr.length - 1] != null) {
                    }
                    else {
                        event.preventDefault();
                    }

                }
            });
        });


that is the code i use for the accordion...i on the beforeActivate event i do a check and based on the outcome i stop the accordion from opening using event.preventDefault(); But was thinking there must be a better way to do this.
Posted
Updated 14-Nov-13 3:00am
v2
Comments
Nelek 14-Nov-13 6:29am    
Ruwaldo 14-Nov-13 8:56am    
I have tried using all of the methods activated, destroy etc...i have found a work around using the beforeActivate event and stoping the default action which stops the accordion expanding, but was hoping there is a better way to do this.

1 solution

Hi Friend,

If possible put some part of code you have done. You may check find option with attribute filter to get perticular panel. If you still need help just paste some code here.

Thanks,
Chetan
 
Share this answer
 
Comments
Ruwaldo 14-Nov-13 9:00am    
I have added some code to the question

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900