Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap dropdown triggers form submit (search)

<div class="btn-toolbar search-dropdown" style="float:left;margin-right:10px;">
    <div class="btn-group">
        <button class="btn btn-small">All Types</button>
        <button data-toggle="dropdown" class="btn btn-small dropdown-toggle"><span class="caret"></span>
        </button>
        <ul class="dropdown-menu" id="search-type">
            <li>
                <label class="checkbox">
                    <input type="checkbox" name="tv" value="TV">TV</input></label>
            </li>
            <li>
                <label class="checkbox">
                    <input type="checkbox" name="movies" value="Movies">Movies</input></label>
            </li>
        </ul>
    </div>
</div>
like image 837
vick Avatar asked Dec 11 '22 17:12

vick


1 Answers

That's because <button> elements submit their own form by default - they inherit the type="submit" attribute.

If you don't want 'em to do so, add the attribute type="button", so it will become a normal button.

like image 68
gustavohenke Avatar answered Dec 17 '22 22:12

gustavohenke