I want to show a JQuery dialog conditionally on click event of an hyperlink .
我有一个类似于条件1的要求,打开一个JQuery对话框,如果条件1不满足,导航到由‘href’标记引用的页面,该页面的单击事件有问题.
I am able to call a function on link's click event. This function now checks the said condition by executing another URL (that executes my Spring controller and returns response).
所有的工作都很完美,只有window.open被弹出窗口拦截器阻止.
$('a[href*=/viewpage?number]').live('click', function(e) {
e.preventDefault();
redirectionURL = this.href;
pageId= getUrlVars(redirectionURL)["number"];
$.getJSON("redirect/" + pageId, {}, function(status) {
if (status == null) {
alert("Error in verifying the status.");
} else if(!status) {
$("#agreement").dialog("open");
} else {
window.open(redirectionURL);
}
});
});
如果我从代码中删除e.preventDefault();
,Popop blocker不会阻止页面,但是对于条件1,它会打开对话框并打开"href"页面.
如果我解决了一个问题,就会给另一个带来问题.我不能同时给这两个条件以正义.
你能帮我解决这个问题吗?
Once this is solved I have another issue to solve i.e. navigation on dialogue's OK event :)