0

Library: Bootstrap 3:Collapse.js.

I have tried

$(document).ready(function () {
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);

});

function endRequestHandler(sender, args) {
    //alert("this should work");
    $('#collapseTwo').collapse.in();

But it throws Uncaught TypeError: undefined is not a function

The alert instead works no problem.

I thought JQuery was undefined but the page where this code is inherits all the appropriate scripts from a masterpage, so that's not the problem.

So, following this advice I went on to trying

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(endRequestHandler);

But I made no progress.

I've also tried to use the body tag, but still no joy.

Can please somebody tell me what I'm doing wrong?

Thanks.

Community
  • 1
  • 1
U r s u s
  • 6,680
  • 12
  • 50
  • 88

1 Answers1

2

Bootstrap and its libraries work mainly with classes and data-bindings.

There is no in() function for the collapse.js of bootstrap. If you want to reset the collapsable to be to collapse in you need to remove the class

$('#collapseTwo').removeClass('in');

This will make it reset.

If you would like the animation too you can trigger this with jquery by simulating a click (or how every your app triggers this collapse to show)

$(<selector for your button>).trigger('click')
Funonly
  • 818
  • 1
  • 8
  • 22