Monday, October 28, 2013

Bootstrap datepicker fancybox conflicts - Solution

When we working with Bootstrap with Fancybox, several time face following javascript error 
"Cannot call method 'split' of undefined" to solution of this issue is :

Add fancybox type (type:'iframe')  in Fancybox Jquery method like

$(".fancybox-html").fancybox({ 
width    : '75%', 
height   : '75%', 
autoSize    : false, 
closeClick  : false, 
fitToView   : false, 
openEffect  : 'none', 
closeEffect : 'none', 
type : 'iframe' 
});

Hope it work for you,
Thank you

Sunday, October 27, 2013

Hide Div when Click Outside - JQuery


When you trying to do the simple hide div when you click on the any part of the page. I got the trick after googling to to hide the div using JQuery. 


HAS() method constructs a new jQuery object from a subset of the matching elements. The supplied selector is tested against the descendants of the matching elements; the element will be included in the result if any of its descendant elements matches the selector.

Hide Div when Click Outside - Trick

 Jquery code 


$(document).mouseup(function (e)
{
              var loginBox = $("#login");
              
             if (loginBox.has(e.target).length === 0)
              
                {
                 loginBox.hide();
               }
 });



HTML Code

<div id="login"></div>