html 양식로드 및 제출을 처리하는 클래스를 만들었습니다.mootools를 사용하여 양식 제출
ND.Form = new Class({
//--- Implements options og events.
Implements: [Options, Events],
//--- Options.
options: {
url: '',
injectTo: ''
},
//--- Initialize the class.
initialize: function (panel, options) {
//--- Set options
this.setOptions(options);
this.panel = panel;
this.loadForm();
},
loadForm: function() {
var req = new Request.HTML({
url: this.options.url,
method: 'get',
onSuccess: function (html) {
$(this.options.injectTo).empty();
$(this.options.injectTo).adopt(html);
var formId = $(this.options.injectTo).getFirst('form').get('id');
$(formId).addEvent('submit', function (e) {
e.stop();
this.submitForm(formId);
} .bind(this));
} .bind(this)
}).send();
},
submitForm: function (formId) {
$(formId).set('send', {
onSuccess: function (resp) {
this.panel.loadContent();
if (resp != null) {
$('lbl_error').empty();
$('lbl_error').setStyles({ 'display': 'block', 'color': 'red' }).set('html', resp);
}
}.bind(this),
onFailure: function (resp) {
if (resp != null) {
$('lbl_error').empty();
$('lbl_error').setStyles({ 'display': 'block', 'color': 'red' }).set('html', resp);
}
}
});
$(formId).send();
}
});
아래 코드를 참조하십시오 그리고 내가 그들보다 더 많은 저장 버튼을 누르면 모든 것이 그 exept, 잘 작동 "this.panel.loadContent();" "submitForm : function (formId)"에서 버튼을 눌렀을 때와 동일한 x 시간이 발생합니다. 어떻게 막을 수 있습니까?
/마틴
글쎄, 내 "this.panel.loadContent();" 나는 당신의 제안을 시도 할 때 여전히 여러 번 불을 뿜는다. 처음 버튼을 한 번로드하면 두 번로드됩니다. 두 번로드됩니다. –
제출을 클릭하지 않고 양식을 제출하면 어떻게됩니까? 나는. 사용자가 텍스트 입력 안에 엔터를 누르면? –