Frage

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 ?

War es hilfreich?

Lösung

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/

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top