0

変数を作成し、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;
    }
);
4

1 に答える 1

1

値を取得する前に変数をバインドしています。

変数を一度 (おそらく Add_Notice... 関数の外側で) 設定してからバインドする必要があります。

于 2013-01-01T10:14:25.217 に答える