var resetForm = function($form) {
//有顆假的Reset按鈕按了以後用javascript做reset,才做畫面重設。
$form.get(0).reset();
_resetJqmForm($form);
},
_resetJqmForm = function($form) {
$form
.find('select:not(select[data-role=slider])').each(_resetSelect).end()
.find('input:checkbox,input:radio').each(_resetRadio).end()
.find('input[data-type=range],select[data-role=slider]').each(_resetSlider).end();
},
_resetSelect = function(index, element) {
$(element).selectmenu('refresh');
},
_resetRadio = function(index, element) {
$(element).checkboxradio('refresh');
},
_resetSlider = function(index, element) {
$(element).slider('refresh');
};
HTML Code Sample:
<form>
......
<button id="reset" type="button" data-theme="b">Reser</button>
</form>
<script type="text/javascript">
$('#reset').live('click', function(e) {
var $form = $(this).parents('form');
resetForm($form);
});
</script>
沒有留言:
張貼留言