Wednesday, March 21, 2012

AJAX Accordion - Disable panel opening when linkbutton clicked

I am using a DataBound accordion that has a table in the headertemplate. The last column of the table contains a linkbutton to select the row and move on to the next page. Is there any way I can disable the panel opening when this button is clicked? It starts to expand the panel but then executes the button click and moves to the next page. It doesnt look great and Im not allowed to move the button into the detail either. I know its unlikely there is such a solution but does anybody know of a way round this?

I have found a solution to this, if anybody wants to know.

If you have the source code for the Accordion, open AccordionBehavior.js and find

_onHeaderClick :function(evt) {

I have added a section near the top, after the first batch of declarations, as such:

//dont open pane if the next button was clicked

if (evt.target.src)

{

var string1 = evt.target.src.toString();// the imageURL of the button

var matchPos1 = string1.indexOf("btnNext.gif");if(matchPos1 > 0)

{

return;

}

}

Of course, this is hard coded to the button's ImageURL, so you may wish to change it so you can pass in the string parameter to make the function more generic, but hey its OK for my needs and its working!! Which Im very happy about!!!!

Hope that helps someone in the future.

No comments:

Post a Comment