I have a button, onclick of that i want to display the modal pop up window. Here's what i have done- Window is displayed for 2 seconds and then it vanishes! what might be the problem?
<script>
$j=jQuery.noConflict();
$j(document).ready(function() {
$j('input[id$=loginbtn]').click(function(event) {
$j('#login').dialog({autoOpen: shallIOpen(),
title: 'Login:',
resizable: false, width: 600,height: 200,
autoResize: true, modal: true,draggable: true,
buttons: [ { text: "Ok", click: function() { $j( this).dialog( "close" ); }} ] })
});
});
function shallIOpen(){
if({!logindisplay}){
return true;
}
else{
return false;
}
}
<body>
<apex:form >
<apex:commandButton value="Click Here to Login" id="loginbtn" action="{!login}"/>
</apex:form>
</body>
logindisplay is a boolean declared in the controller
public boolean logindisplay{get;set;}
//constructor
public jPopUpController(){
logindisplay=true;
}
//method called when clicked on the button
public void login(){
logindisplay=true;
}
Where have i gone wrong? Pop is appearing for only 2 secods and it is disappearing! when i clicked on the button.
Attribution to: Akash Nidhi P S
Possible Suggestion/Solution #1
Perhaps the underlying button submit is causing this; adding event.preventDefault() to your click function should stop that.
Attribution to: Keith C
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/33841