
Untitled
By: a guest on
May 2nd, 2012 | syntax:
None | size: 2.01 KB | hits: 21 | expires: Never
How to prevent a postback call in a lightbox/modal
$(document).ready(function () {
var display = $('.lightbox-overlay').css('display');
$('.lightbox').click(function (e) {
if ($('.lightbox-overlay').length != 0) {
$("body").css("overflow", "hidden");
}
$('.lightbox-overlay').animate({ 'opacity': '.9' }, 300, 'linear');
$('.dialog-ui').animate({ 'opacity': '1.00' }, 300, 'linear');
$('.lightbox-overlay, .dialog-ui').css('display', 'block');
e.preventDefault();
});
$('.close-btn').click(function () {
closeBox();
});
$('.lightbox-overlay').click(function () {
closeBox();
});
});
function closeBox() {
$('.lightbox-overlay, .dialog-ui').css('display', 'none');
$("body").css("overflow", "visible");
}
<a class="lightbox click-here-link" href="#">click here</a>
<div class="dialog-ui">
<div class="inner">
<a class="close-btn" href="#">close</a>
<h3>Build your product</h3>
<div class="data-row clearfix"> <span class="product-build-steps">1</span><span id="ctl21_pb_LBL_og1150"><label>Select Hand</label></span> <select id="ctl21_pb_DDL_og1150" onchange="javascript:setTimeout('__doPostBack('ctl21$pb_DDL_og1150','')', 0)" name="ctl21$pb_DDL_og1150"> <option value="HRH" selected="selected">Right Hand</option> <option value="LRH">Left Hand (+£1.99)</option>
</select>
$('#selectTag').change(function(e){
e.preventDefault();
});
var container = //dom selector for the div or whatever that has all the selects
$(container).find('select').each(function(){
$(this).removeAttr('onchange');
});
$('form').submit(function(){
//You might have to add some condition here before returning false
return false;
});