Home › Forums › JavaScript › Js running on 1.7.2 but not running in 1.10.2
- This topic is empty.
-
AuthorPosts
-
October 27, 2013 at 8:00 am #154185
opus
ParticipantHi,
Im getting crazy please help!
I have this js running perfectly using 1.7.2 js (open a popup div when clicked on).When i move this code to my WP site using js 1.10.2 the link send me to an actual link instead of activating the popup.
Any idea what can i do?
I know this is the problem because when i change the js version to 1.10.1 on the jsfiddle example i encounter the same issue.
October 27, 2013 at 9:28 am #154192opus
ParticipantOk, so i changed the js version running on the WP site to 1.7.2 and still it doesn’t work! :( This is the page i am trying to run the script on.
the link that should activate the js is in the bottom left corner of the world map (screen shot) but when you click it it tries to follow the link instead of opening the pop-up
Please help :)
October 27, 2013 at 11:49 am #154207__
Participant…when i change the js version to 1.10.1 …
I think you’re talking about the jQuery version, yes?
jQuery deprecated and removed its
live
method. Switch those calls toon
instead and you’ll be fine.October 27, 2013 at 1:21 pm #154210opus
ParticipantThnks traq! Did it but still doesn’t activate the popup when clicked on (see here)
I changed
function deselect() {
$(“.pop”).slideFadeToggle(function() {
});
} $(“#contact”).removeClass(“selected”);$(function() {
$(“#contact”).live(‘click’, function() {
if($(this).hasClass(“selected”)) {
deselect();
} else {
$(this).addClass(“selected”);
$(“.pop”).slideFadeToggle(function() {
$(“#email”).focus();
});
}
return false;
});$(".close").live('click', function() { deselect(); return false; });
});
$.fn.slideFadeToggle = function(easing, callback) {
return this.animate({ opacity: ‘toggle’, height: ‘toggle’ }, “fast”, easing, callback);
};to
function deselect() { $(“.pop”).slideFadeToggle(function() { });
} $(“#contact”).removeClass(“selected”);
$(function() { $(“#contact”).on(‘click’, function() { if($(this).hasClass(“selected”)) { deselect(); } else { $(this).addClass(“selected”); $(“.pop”).slideFadeToggle(function() { $(“#email”).focus(); }); } return false; });
$(".close").on('click', function() { deselect(); return false; });
});
$.fn.slideFadeToggle = function(easing, callback) { return this.animate({ opacity: ‘toggle’, height: ‘toggle’ }, “fast”, easing, callback); };
Any other ideas?
October 27, 2013 at 1:49 pm #154214__
ParticipantI don’t know. It works with your fiddle, which would imply there is something different on the actual page.
The link in your fiddle has the id
contact
; while the link on your page has the idpopup
. Might be other things wrong, but that’s probably a good place to start.October 27, 2013 at 2:20 pm #154215opus
Participant:( just some games i tried… even when i turn it back like in the fiddle still no luck.
Thanks for trying…October 27, 2013 at 3:18 pm #154223__
ParticipantLook at your function that sets this all up:
(function($) { $("#contact").on('click', function() { if ($(this).hasClass("selected")) { deselect(); } else { $(this).addClass("selected"); $(".pop").slideFadeToggle(function() { $("#email").focus(); }); } return false; }); $(".close").on('click', function() { deselect(); return false; }); });
You don’t actually call it. : )
(function($) { $("#contact").on('click', function() { if ($(this).hasClass("selected")) { deselect(); } else { $(this).addClass("selected"); $(".pop").slideFadeToggle(function() { $("#email").focus(); }); } return false; }); $(".close").on('click', function() { deselect(); return false; }); })($);
^— see the invocation (
( $ )
) at the end?October 27, 2013 at 4:20 pm #154224opus
ParticipantTried it just now, still no luck… maybe i am missing something that calls all the function on page load or something?
October 27, 2013 at 4:58 pm #154226__
ParticipantThere is an undefined variable,
bdVar
, on line 697 of your global.js script. Change that line fromif( bdVar.use_fancy == 'false' ){
to
if( typeof bdVar !== 'undefined' && bdVar.use_fancy == 'false' ){
To be clear, I can run your function (above) in the console, on your page, and then clicking on the link works. The code works correctly; there’s something on the page that is interfering.
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.