I have a link:
<a href="#" onClick="javascript:isRename();" class="current-text">rename</a>
which invokes isRename() function:
function isRename(){
var i = getCheckboxCount();
if(i==1){
showInputDialog(getCheckboxName(),'Rename', 'Enter the name of file/directory',null);
}
}
function showInputDialog(a,b,c,okFunc){
$.fn.InitInputDialog(a,b,c,okFunc);
$.fn.fadeInCommon();
};
It shows a modal window. This window has a close button.
$("#CloseInputButton").off('click'); //MY CLOSE BUTTON IN MODAL WINDOW
$("#CloseInputButton").click(function(){
fadeOutCommon();
});
$.fn.fadeOutCommon = function(){
//transition effect
$('#mask').fadeTo("slow",0.0,function(){
$(dialogID).hide();
$('#mask, .window').hide();
});
};
It works fine before I press the close button. My web page refreshes and fadeOutCommon animation doesn't work at all! I think it happens because of refreshing web page! How can I disable refreshing web page?
Thanks
I have a link:
<a href="#" onClick="javascript:isRename();" class="current-text">rename</a>
which invokes isRename() function:
function isRename(){
var i = getCheckboxCount();
if(i==1){
showInputDialog(getCheckboxName(),'Rename', 'Enter the name of file/directory',null);
}
}
function showInputDialog(a,b,c,okFunc){
$.fn.InitInputDialog(a,b,c,okFunc);
$.fn.fadeInCommon();
};
It shows a modal window. This window has a close button.
$("#CloseInputButton").off('click'); //MY CLOSE BUTTON IN MODAL WINDOW
$("#CloseInputButton").click(function(){
fadeOutCommon();
});
$.fn.fadeOutCommon = function(){
//transition effect
$('#mask').fadeTo("slow",0.0,function(){
$(dialogID).hide();
$('#mask, .window').hide();
});
};
It works fine before I press the close button. My web page refreshes and fadeOutCommon animation doesn't work at all! I think it happens because of refreshing web page! How can I disable refreshing web page?
Thanks
- 1 You possibly won't need to "disable refresh", as a sidenote: disabling refresh on user's browser is what I would consider offensive and frustrating... Either change your UI design or deal with it. – Andreas Wong Commented Mar 22, 2012 at 6:04
-
onClick="javascript:isRename();"
<- you're mixing handler syntax with href syntax.javascript:
shouldn't be there. – SpliFF Commented Mar 22, 2012 at 6:12
2 Answers
Reset to default 3Just write down return false;
will do that task.
<a href="#" onClick="javascript:return isRename();" class="current-text">rename</a>
function isRename(){
var i = getCheckboxCount();
if(i==1){
showInputDialog(getCheckboxName(),'Rename', 'Enter the name of file/directory',null); }
return false;
}
Also have look to
e.preventDefault()
will prevent the default event from occuring, e.stopPropagation()
will prevent the event from bubbling up and return false will do both.
you can put return false
in your click methods
$("#CloseInputButton").click(function(){
fadeOutCommon();
return false;
});