我正在尝试使用骨架.js进行表单提交,当我单击“提交”时,它将刷新表单。我在这里添加了我的js代码。是否有任何来源可以从中获取一些有关主干js的详细示例,并有正确解释的主干js。我是骨干js的新手,正在尝试学习它。
$(document).ready(function () {
Models.morderfaq = Backbone.Model.extend({
action: "ae-morder_faq-sync",
defaults: {
}
});
Collections.morderfaqs = Backbone.Collection.extend({
model: morderfaq,
el: '#save_faq_form',
action: 'ae-fetch-morder_faq',
initialize: function () {
}
});
Views.morderfaq_view = Backbone.View.extend({
el: '#save_faq_form',
events: {
"submit #save_faq_form": "syncChange"
},
initialize: function (options) {
_.bindAll(this, 'syncChange');
this.model = new morderfaq();
},
syncChange: function (event) {
event.preventDefault();
var self = this;
console.log('clicked');
self.$el.find('input,textarea,select').each(function () {
self.model.set($(this).attr('name'), $(this).val());
});
}
});
new Views.morderfaq_view();
});
HTML代码
<form class="post et-form" id="save_faq_form" novalidate="novalidate">
<div class="form-group clearfix">
<div class="input-group">
<label for="" class="input-label">1. send me
</label>
<textarea name="morder_faq_491" class="input-item input-full" id="morder_faq_491" value="" placeholder="Enter Text...">
</textarea>
</div>
</div>
<div class="form-group">
<button class="btn-save btn-submit" type="submit">SEND</button>
<input type="hidden" class="input-item save_faq_nonce" name="_wpnonce" value="fd75e383ec">
</div>
</form>