Hi Guys,
I am writing this post because some one comment on my blog and asked me for this requirement, i am happy to help him,
http://anuragsfdc.blogspot.in/p/salesforce-limits.html
his requirement is to show Yes /No buttons in place of Ok/Cancel buttons of javascript confirm function.
so for this i am creating a custom pop up dialog using JQuery.
here the code for same:-
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page> | |
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"/> | |
<script src="//code.jquery.com/jquery-1.9.1.js"></script> | |
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> | |
<script> | |
// jquery funtion for pop up. | |
$(function () { | |
$('#a').click(function(){ | |
$( '<div></div>' ).dialog({ | |
resizable: false, | |
height:140, | |
modal: true, | |
open: function() { | |
var markup = 'Are You Sure?'; | |
$(this).html(markup); | |
}, | |
title: "Confirmation", | |
buttons: { | |
"Yes": function() { | |
$( this ).dialog( "close" ); | |
yesFunction(); | |
}, | |
"No": function() { | |
$( this ).dialog( "close" ); | |
} | |
} | |
}); | |
}); | |
}); | |
function yesFunction(){ | |
// Write you code/logic of js here... | |
alert("call Apex method."); | |
} | |
</script> | |
<apex:form> | |
<h4>Click on Button for custom pop up. </h4> | |
// Button. | |
<div id="a" class="btn"> | |
Ok | |
</div> | |
</apex:form> | |
</apex:page> |
hope it helps, happy coding...
Thanks