2013-09-26 1 views
1

Я пытаюсь использовать SimpleModal в качестве подтверждения для отказа от электронной почты, то есть нажатие на адрес электронной почты всплывает модальный, пользователи, которые согласны с отказом от права, могут отправлять электронную почту с помощью метода mailto: пользователи, которые отказываются, не получают всплывающее окно ,SimpleModal - Как передать адрес электронной почты для подтверждения?

  • У меня есть пара десятков адресов электронной почты на одной странице, так что мне нужно передать адрес сценария
  • Оговорка используется на других страницах, так что я хотел бы включить в HTML копию как ну, это около 4 абзацев.

Это то, что я до сих пор, она работает почти за исключением нет почтового клиента всплывающего окна на подтверждении:

<a href="mailto:[email protected]" class="confirm">[email protected]</a> 

<div id='confirm'> 
    <div class='header'><span>Confirm</span></div> 
    <div class='message'></div> 
    <div class='buttons'> 
     <div class='no simplemodal-close'>Cancel</div> 
     <div class='yes'>Confirm</div> 
    </div> 
</div> 

и JavaScript:

jQuery(function ($) { 
    $('a.confirm').click(function (e) { 
     e.preventDefault(); 

     msg = 'this is the copy of the confirmation dialog I want to pop up, it goes on and on and on'; 

     // example of calling the confirm function 
     // you must use a callback function to perform the "yes" action 
     confirm(msg, function() { 
      window.location.href = hrefval; 
     }); 
    }); 
}); 

function confirm(message, callback) { 
    $('#confirm').modal({ 
     closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>", 
     position: ["20%",], 
     minWidth: '660px', 
     minHeight: '400px', 
     overlayId: 'confirm-overlay', 
     containerId: 'confirm-container', 
     onShow: function (dialog) { 
      var modal = this; 

      $('.message', dialog.data[0]).append(message); 

      // if the user clicks "yes" 
      $('.yes', dialog.data[0]).click(function() { 
       // call the callback 
       if ($.isFunction(callback)) { 
        callback.apply(); 
       } 
       // close the dialog 
       modal.close(); // or $.modal.close(); 
      }); 
     } 
    }); 
} 

ответ

0

вычислен это, я только что для явного захвата значения href.

jQuery(function ($) { 
    $('a.confirm').click(function (e) { 
     e.preventDefault(); 

     href = $(this).attr('href'); 

     msg = 'this is the copy of the confirmation dialog I want to pop up, it goes on and on and on'; 

     // example of calling the confirm function 
     // you must use a callback function to perform the "yes" action 
     confirm(msg, function() { 

      window.location.href = href; 
     }); 
    }); 
});