Reputation: 21
This little snippet here works just fine in JSFiddle, but it does nothing when I put it in with the tabs within a PHP file for a WordPress button. I currently have standard JavaScript on it to open a popup dialog with "Ok" & "Cancel" but I'd like to use "Yes", "No" & "Cancel" instead.
What's the issue here?
http://jsfiddle.net/vvjj8/617/
HTML
<li class="level3 item578"><a id="btnOpenDialog" value="Confirm Dialog Box" href="#"><span>ArmA 2</span></a>
</li>
<div id="dialog-confirm"></div>
jQuery
function fnOpenNormalDialog() {
$("#dialog-confirm").html("Do you have Play WithSix installed?");
// Define the Dialog and its properties.
$("#dialog-confirm").dialog({
resizable: false,
modal: true,
title: "ArmA 2",
height: 250,
width: 360,
buttons: {
"Yes": function () {
$(this).dialog('close');
window.location.href = "http://www.fogamers.com/arma2.php";
},
"No": function () {
$(this).dialog('close');
window.open('http://play.withsix.com/', '_blank');
},
"Cancel": function () {
$(this).dialog('close');
}
}
});
}
$('#btnOpenDialog').click(fnOpenNormalDialog);
Errors
Uncaught TypeError: undefined is not a function (index):76
(anonymous function) (index):76
f.event.dispatch jquery.min.js:3
h.handle.i
Uncaught TypeError: undefined is not a function widgetkit-dd62f244.js:13
(anonymous function) widgetkit-dd62f244.js:13
o jquery.js?ver=1.7.2:2
p.fireWith jquery.js?ver=1.7.2:2
w jquery.js?ver=1.7.2:4
d
Uncaught TypeError: undefined is not a function (index):203
(anonymous function) (index):203
o jquery.min.js:2
p.fireWith jquery.min.js:2
e.extend.ready jquery.min.js:2
c.addEventListener.B
Upvotes: 0
Views: 827
Reputation: 3582
What cpilko said is valid, but if you prefer to use the $
variable in your code (it can be easier for multiple reasons) then redefine it when you call your jquery like so:
<script>
jQuery(document).ready(function($) {
// you can now use the $ variable
$("#dialog-confirm").html("Do you have Play WithSix installed?");
)};
</script>
Upvotes: 2
Reputation: 11852
Wordpress uses jQuery noconflict mode. Try replacing all the $
in your code with jQuery
.
function fnOpenNormalDialog() {
jQuery("#dialog-confirm").html("Do you have Play WithSix installed?");
...
Upvotes: 1