Coda Chang Coda Chang - 1 month ago 15
Ajax Question

jQuery trigger click function via done not working

There is a button, click it, it will open a modal and fetch data via

ajax
.

Besides, there are some tabs on the modal. When the user click the button, it will open the modal and click the tab by default.

It's hard to describe, so I've written the following code.

$('#open_mission_btn > .the_btn').click().done(function(){
$('#my_books_bookmark').click();
});


But it seems not work.

Answer

Trigger your click event in the success/done function of your ajax call

success:function(data) {
$('#my_books_bookmark').click();
}

to set the default tab to be open if you are using bootstrap you can do the following:

$('#myTabs a[href="#default"]').tab('show');

http://getbootstrap.com/javascript/#tabs-usage

Comments