Search code examples
jqueryjquery-ui-resizable

How to check if a div is resizable()


What seems like a simple thing to do is not playing ball. How do I check if an element is resizable?

Ive tried some testing on jsfiddle without much luck. Ive tried looking at the official instructions page here: http://jqueryui.com/demos/resizable/#method-option and a bit of googling and checking for the answer on stackoverflow but still cant get it to give me the correct response. The below code comes back 'disabled' regardless.

heres the fiddle: http://jsfiddle.net/dbKtP/11/

$("#a").resizable();

if ($("#a").resizable("option","enable") == true){
   alert("enabled");       
} else {
   alert("disabled");   
}

Can anyone solve this resonably simple but perplexing issue?


Solution

  • It's called "disabled" not "enable". Don't forget to also reverse the boolean when you correct it.

    i.e.:

    if ($("#a").resizable("option","disabled")){
       alert("disabled");   
    } else {
       alert("enabled");       
    }
    

    PS. It's kind of silly to compare to true and false.