I'm using the jQuery Masked Input Plugin from here: Digital Bush
I'm also using the jQuery FancyBox plugin.
As far as I can tell, they don't play nice together.
My masked inputs do not work if in the FancyBox, though they work outside (same id #phone). FancyBox displays fine.
The fancy box is on the page, display: none at page load....so I attempted to use the callbackOnShow setting, but id does not want to work.
JAVASCRIPT:The alert function won't fire
$(document).ready(function() {
loadScroll();
$("a.inline").fancybox({
'callbackOnShow' : function(){alert('shown');}
});
});
Found it, callbackOnShow should be onComplete.
$(document).ready(function() {
loadScroll();
$("a.inline").fancybox({
'onComplete' : function(){alert('shown');}
});
})
Found here: fanbcyBox/Blog
Related
I have a problem with the wordpress and with Jquery.
I have this code to show and hide a responsive navigation on the left :
$('.menu').on('click', function(){ if ($('.responsive__menu').hasClass('is-open')) {
$('.responsive__menu').removeClass('is-open');
$('.menu').removeClass('is-active');} else {
$('.responsive__menu').addClass('is-open');
$('.menu').addClass('is-active');}});
It works with my website without Wordpress, but once in Wordpress, it seems that half of the code works : the creation of the cross to close the menu except that the menu does not appear.
Can you enlighten me on some points?
The script is loaded, are there a faster and easier way to transform the code with jquery and toogle () ?
It can only be a trouble about code but why it does not work anymore once on Wordpress ?
Thanks a lot for your help, before asking the question I tried many things. ^^
If it works with any of your websites means the code is good, just you might have conflicts in your css, so include your css which is menu related last, and if it doesn't work either, post your css code, so we could see better what's going on, and there is not need for so much code. Initialize your menu without class .open , in your html and use JQUERY:
$('.menu').on('click', function(){
$(".responsive_menu).toggleClass('open');
});
jQuery comes with wordpress in non-conflict mode , to make sure everything works you should use jQuery variable instead of the $ variable.
you can alternatively do the following
jQuery(document).ready(function($) {
// $ variable can be used here
$('.menu').on('click', function() {
if ($('.responsive__menu').hasClass('is-open')) {
$('.respons__menu').removeClass('is-open');
$('.menu').removeClass('is-active');
} else {
$('.responsive__menu').addClass('is-open');
$('.menu').addClass('is-active');
}
});
});
I have a WordPress site located at http://test.bcminiwarehouses.com
I am trying to add 2 attributes to the Make a Payment link in the menu so that it functions like clicking on the + on the top right.
When I inspect the element in Chrome and manually add the attributes, the link works as desired. However the jquery command appears not to be functioning to automatically add these attributes.
The code that can be viewed in the source code is:
$(".menu-item-6654").attr('data-target', '.x-widgetbar');
$(".menu-item-6654").attr('data-toggle', 'collapse');
Maybe there's a conflict between jQuery and Wordpress,try to do:
jQuery(document).ready(function($) {
$(".menu-item-6654").attr('data-target', '.x-widgetbar');
$(".menu-item-6654").attr('data-toggle', 'collapse');
});
put your code in
$(function() {
});
I have never used or developed any slider for webpage yet and this is my first time.So I searched for a tutorial and found one where he was using the following JQuery code to silde the divs on webpage.
$(document).ready(function() {
$('#controls').on('click', 'span', function(){
$("#inner_container").css("transform","translateX("+$(this).index() * -450+"px)");
});
})
Since I had single slider on page and there was no requirement of jQuery for any other purpose,I decided not to use JQuery and thus changed the script to
function slide(i)
{
document.getElementById("inner_container").style.transform="translateX("+(i*-450)+"px)"
}
and called this function as
<div id="controls"><span onclick='slide(3);'>Show Third</span></div>
Its working fine but I wanted to know that is there any pitfall with this replacement as I am using this for navigation on my website and my entire site is dependent on it?
I am trying to do a slow reveal on a particular div with an id of 'contentblock' on page load. This is my first time trying to code something in jQuery and I continue to fail. The following is my latest attempt, but I'm a complete newbie to this and surprisingly google hasn't been a whole lot of help.
<script type='text/javascript'>
$(window).onload(function(){
$('#contentblock').slideDown('slow');
return false;
});
</script>
before that I also had the following instead of the window onload line above:
$(document).ready(function(){
But that didn't have any success either. Can someone help a jQuery newbie out?
First, you'll need to make sure the element is hidden (or it won't be shown, since it's already visible). You can do this in either CSS or JavaScript/jQuery:
#contentblock {
display: none;
}
Or:
$('#contentblock').hide();
If you use CSS to hide the element you need to be aware that the element will remain hidden in the event of JavaScript being disabled in the user's browser. If you use JavaScript there's the problem that the element will likely flicker as it's first shown and then hidden.
And then call:
$(window).load(function(){
$('#contentblock').slideDown('slow');
});
I've made two amendments to your jQuery, first I've changed onload to load and I've also removed the return false, since the load() method doesn't expect any value to be returned it serves no purpose herein.
For the above jQuery you can use instead:
$(document).ready(function(){
$('#contentblock').slideDown('slow');
});
$(document).ready(function(){
if($('#contentblock').is(':hidden'))
{
$('#contentblock').slideDown('slow');
}
});
if you have jquery added to your project and your div is display none ... something like this should work.
I am trying to create a overlay dialog box using CSS . I wrote the css but I am not able to display the overlay dialog box. Any help would be greatly appreciated.
Check out my attempt here. Also this should work in IE9 and firefox.
http://jsfiddle.net/tGDKT
why not just use jQuery UI's dialog:
http://jsfiddle.net/maniator/tGDKT/15/
$(function() {
$('.clickme').click(function() {
$('iframe').dialog();
});
});
You could also attach the method in the javascript, unobtrusive style. Give the <a> an id or:
$('a').click(calculateEmbeddedWindowSize);
... would call the function for every link on the page.
I keep getting "calculateEmbeddedWindowSize is not defined" in the console. Your javascript does not seem to be there at all on the page.
Edit - Try this: http://jsfiddle.net/tGDKT/7/