开发者

Facebox only opens once on first Jquery form submission

I have a dashboard page where the user can enter an asset code or ID to search on, and on clicking the search button or hitting enter the search result comes up in a Facebox modal. So far, so good. However, when the user tries to perform a second search, the Facebox result modal fails to open, despite the JQuery POST happening correctly and the response HTML being returned as it should be. My function that binds to the submit function and performs the ajax POST is as follows:

  // attach a submit handler to the form
  $("#astsrch").submit(function(event) {    
    //$('a[rel*=facebox]').facebox();                                       
    // stop form from submitting normally
    event.preventDefault(); 

    // get some values from elements on the page:
    var $form = $( this ),
        term = $form.find( 'input[name="assetsearch"]' ).val(),
        url = $form.attr( 'action' );

    // Send the data using post and put the results in a div
    $.post( url, { assetsearch: term } ,
      function( data ) {
          $.facebox(data);
      }
    );
  });

It seems that something is happening when the Facebox close butto开发者_如何转开发n is clicked that prevents any further Facebox from opening when the search form is submitted via the above function.


look at this post. it's similar to yours. try to bind a click event on the submit button.

something like:

$(document).ready(function() {
    $('#astsrch').live('click', function() {
        $.get($(this).attr("action"), function(data){
            $.facebox(data);
        });
    }); 
});

good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜