0

下面给出的是我的一段代码。即使在所有正确的地方提供了“return false”,jQuery colorbox 也会导致我的页面发布到我想要避免的服务器。虽然颜色框可以正确呈现,但我不希望整个页面都发回相同的内容。提前致谢。

FI.quickView = {

    init: function (obj) {

        $(obj).click(function (e) {
            e.preventDefault();
        });

        $(obj).colorbox({
            href: "somefile.html",
            width: 890,
            height: 680,
            onLoad: function () { return false; },
            onOpen: function () { return false; }
        });
    }
}
4

1 回答 1

0

No need in this code, because it doesn't have any sense:

onLoad: function () { return false; }, 
onOpen: function () { return false; } 

It's hard to understand what is obj, but if you want prevent form submit, then use this:

$('form').submit(function(e){
    e.preventDefault();  
});

Where form is selector of your form and this code you can add to onLoad event.

于 2012-10-09T13:46:04.393 回答