Search code examples
javascriptjqueryjquery-ui-resizable

Inserting javascript when jquery resize is finished


I'm using the jQuery UI resize function, and when user is finished with the operation I'd like it to run this code:

var pl=$('#player iframe')[0];pl.src=pl.src;

Would a callback work? How would I insert it into the resize function?

Specifically, the code I'm using for resize is this:

 $(function() {
$( ".resizableaspect" ).resizable({
  aspectRatio: true,
    helper: "ui-resizable-helper"
});
});

Solution

  • You are using jQueryUI I think.
    This is the official documentation:
    http://jqueryui.com/resizable/

    The event stop is called when you have finished to resize your element.
    Other event are:
    - create
    - resize
    - start
    - stop

    Try this:

    $(function() {
        $( ".resizableaspect" ).resizable({
          aspectRatio: true,
            helper: "ui-resizable-helper",
            stop: function(e, ui) {
                 var pl=$('#player iframe')[0];pl.src=pl.src;
            }
        });
     });