How to trigger jquery Resizable resize programmatically?

后端 未结 5 1025
太阳男子
太阳男子 2020-12-06 00:21

I have a div element which is made jquery Resizable. It has alsoResize option set, so other elements resize simultaneously.

What I want to do, is to set size of this

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-06 00:44

    Hack Disclaimer (tested on jQuery 1.12.4):

    This basically waits for the dialog to be opened and then increments by 1px (which forces the resize() event) and then decrements by 1px (to regain original size)

    just say this in the dialog open event handler:

     $(this)
    .dialog("option","width",$(this).dialog("option","width")+1)
    .dialog("option","width",$(this).dialog("option","width")-1);
    

    note:

    This may not work with show effects (like fadeIn,slideDown etc) as the "resizer" code executes before the dialog is fully rendered.

提交回复
热议问题