I am trying to do this one http://jquerywall.com/demo-multi-transfer-jquery-ui-selectable/ But the problem is that this multiselect plugin has some buttons.When i click any of these buttons my page gets posted and goes to its methods. Here are my buttons
<div id="transfer-buttons">
<button id="add-button">Add →</button>
<button id="add-all-button">Add All *→</button>
<button id="remove-button">← Remove</button>
<button id="remove-all-button">←* Remove All</button>
</div>
here are my buttons functions
<script type="text/javascript">
$(function () {
$("#add-button").click(add);
$("#add-all-button").click(addAll);
$("#remove-button").click(remove);
$("#remove-all-button").click(removeAll);
$("#source-list, #target-list").selectable();
addHiglightPlugin();
});
what should i do?
Try adding a type="button"
attribute to your buttons. When <button>
has no type specified it acts like a submit button.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button
The other thing you can do is prevent default action in your event handlers:
function add(e){
e.preventDefault();
// your code here
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.