How to prevent form submit

限于喜欢 提交于 2019-12-05 08:51:44

Sammy binds itself to forms to enable you to register routes for them as well.

<form action="#1234" method="post">

JS:

Sammy(function() {
    this.post('#:id', function() {
        // do something...

        return false; // avoid form submission
    });

    // ...
}).run();
krzychu

I also had this problem and I found a solution in this answer. Here is how you can make Sammy.js to leave the forms alone:

Sammy(function() {

    // Your routing.. 
    this.get('#:id', function () {
       //do something....
    }); 


    // Make Sammy.js leave the forms alone!
    this._checkFormSubmission = function(form) {
        return false;
    };

}).run();

Works like it should :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!