我创建了一个变量targetForm
并尝试将其与submit()
. 但是,当我调用函数并触发变量来提交表单时,绑定函数不会捕获提交事件。
var targetForm;
function Add_Notice_Message(evt){
alert('set up form');
targetForm = document.notification_form;
targetForm.classname= 'TTWForm';
targetForm.method = "post";
targetForm.action = '';
targetForm.novalidate = '';
alert('beforesubmmit');
targetForm.submit();
}
$( targetForm ).bind(
"submit",
function( event ){
alert('submit');
var $form = $(this), type;
type = $form.find('#type').val();
var options = {
category:'projects',
message: 'Sample Notification'
};
notifications.createNotification(options);
return false;
}
);