I am using this code:
$(\'body\').click(function() {
$(\'.form_wrapper\').hide();
});
$(\'.form_wrapper\').click(function(event){
event.stopPropagatio
Built off of prc322's awesome answer.
function hideContainerOnMouseClickOut(selector, callback) {
var args = Array.prototype.slice.call(arguments); // Save/convert arguments to array since we won't be able to access these within .on()
$(document).on("mouseup.clickOFF touchend.clickOFF", function (e) {
var container = $(selector);
if (!container.is(e.target) // if the target of the click isn't the container...
&& container.has(e.target).length === 0) // ... nor a descendant of the container
{
container.hide();
$(document).off("mouseup.clickOFF touchend.clickOFF");
if (callback) callback.apply(this, args);
}
});
}
This adds a couple things...
I hope this helps someone!