javascript - Find elements which have jquery widgets initialized upon them -


i using jquery-file-upload widget (although believe question can generalize jquery widget). api instructs user initialize the widget using fileupload method, thus:

$('#fileupload').fileupload(); 

my question is: without knowing ids, how can find #fileupload (and other elements have had .fileupload() called upon them?

jquery file upload uses jquery ui widget factory under hood, , factory known register widgets instances elements extend using data().

therefore, can use filter() , write like:

// restrict ancestor if can, $("*") expensive. var uploadified = $("#yourancestor *").filter(function() {     return $(this).data("fileupload"); }); 

update: jquery ui 1.9 onwards, the data() key becomes widget's qualified name, dots replaced dashes. therefore, code above becomes:

var uploadified = $("#yourancestor *").filter(function() {     return $(this).data("blueimp-fileupload"); }); 

using unqualified name still supported in 1.9 deprecated, , support dropped in 1.10.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -