I have the following codes, saveBt, should not submit when user selects cancel on confirm however it seems it still submits cause I have onClickTopics, I need this onclicktopics to reload a struts jquery grid. Any workarounds?
$("#saveBt").click(function(event){
event.preventDefault();
if($('#Form').valid()){
if (confirm("Are you sure ?")) {
return true;
} else {
return false;
}
}
});
<sj:a id="saveBt" onClickTopics="reloadGrid" name="saveChannel" value="saveChannel">Save</sj:a>
UPDATE: Need onClicks to reload grid via :
<sj:a id="saveBt" onClickTopics="reloadGrid" name="save" value="save">Save</sj:a>
<sjg:grid id="gridTable" reloadTopics="reloadGrid" resizable="true"
autowidth="true">
Ended up with:
function validator() {
if (confirm("Are you sure you want to save?")) {
$("#Form").submit();
$("#refresh_gridTable").click();
}
}
<sj:a id="saveBt" onclick="return validator();">Save</sj:a>
Struts jquery Grid creates a refresh button via setting : navigatorRefresh="true"
just had to click it after submit.