문제

I have an external jQuery library that creates a popup.

Example: (This is rendered to page from custom control) My external javascript does something such as.

  <script>
  $(function() {
    $( "#dialog" ).dialog({
      autoOpen: false,
      show: {
        effect: "blind",
        duration: 1000
      },
      hide: {
        effect: "explode",
        duration: 1000
      }
    });

    $( "#opener" ).click(function() {
      $( "#dialog" ).dialog( "open" );
    });
  });
  </script>

Now I would like to add additional behavior after the first one finish executing

  <script>

    $( "#opener" ).click(function() {
      // Add additional stuff here 
    });
  });
  </script>

Any ideas how to achieve this ?

도움이 되었습니까?

해결책

Unfortunately there's no way of handling this directly. But you have a workaround. This is only recommended for cases where the order is important.

The trick is done by means of delegate

$(document).delegate( '#myLink', 'click', function(e){
  // .. do something
});

You can test this online. http://jsfiddle.net/augusto1982/F9G4g/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top