LA_
LA_

Reputation: 20429

How to cancel form submit for btn-primary within form-actions of Twitter Bootstrap?

<div class="form-actions">
  <button class="btn btn-primary" id="btn-next">Next</button>
  <button type="reset" class="btn">Reset</button>
</div>

$("#btn-next").click(function(event) {
    $('#tab li.active').next().find('a[data-toggle="tab"]').click();
});

When Next is pressed, form is submitted. How can I cancel it? demo

Upvotes: 0

Views: 4821

Answers (2)

periklis
periklis

Reputation: 10188

Make it an anchor, not a button:

<a class="btn btn-primary" id="btn-next">Next</a>

Upvotes: 9

ShankarSangoli
ShankarSangoli

Reputation: 69915

Just return false from the click handler.

$("#btn-next").click(function(event) {
    $('#tab li.active').next().find('a[data-toggle="tab"]').click();
    return false;
});

Demo

Upvotes: 1

Related Questions