Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 2.01 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to prevent a postback call in a lightbox/modal
  2. $(document).ready(function () {
  3.                 var display = $('.lightbox-overlay').css('display');
  4.                 $('.lightbox').click(function (e) {
  5.                     if ($('.lightbox-overlay').length != 0) {
  6.                         $("body").css("overflow", "hidden");
  7.                     }
  8.                     $('.lightbox-overlay').animate({ 'opacity': '.9' }, 300, 'linear');
  9.                     $('.dialog-ui').animate({ 'opacity': '1.00' }, 300, 'linear');
  10.                     $('.lightbox-overlay, .dialog-ui').css('display', 'block');
  11.                     e.preventDefault();
  12.                 });
  13.  
  14.                 $('.close-btn').click(function () {
  15.                     closeBox();
  16.                 });
  17.  
  18.                 $('.lightbox-overlay').click(function () {
  19.                     closeBox();
  20.                 });
  21.             });
  22.  
  23.             function closeBox() {
  24.                 $('.lightbox-overlay, .dialog-ui').css('display', 'none');
  25.                 $("body").css("overflow", "visible");
  26.             }
  27.        
  28. <a class="lightbox click-here-link" href="#">click here</a>
  29.     <div class="dialog-ui">
  30.     <div class="inner">
  31.         <a class="close-btn" href="#">close</a>
  32.         <h3>Build your product</h3>
  33.  
  34.         <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>
  35.  
  36. </select>
  37.        
  38. $('#selectTag').change(function(e){
  39.    e.preventDefault();
  40. });
  41.        
  42. var container = //dom selector for the div or whatever that has all the selects
  43. $(container).find('select').each(function(){
  44.    $(this).removeAttr('onchange');
  45. });
  46.        
  47. $('form').submit(function(){
  48.      //You might have to add some condition here before returning false
  49.      return false;
  50. });