Chris Domigan wrote:
> Is there any way I can change the callback functions after the initial 
> .jqm() call? I'm wanting to have a standard "widget" that performs 
> similar to the prompt() function in javascript. But I want to 
> dynamically add a callback depending on when/where in the site it's 
> being used.
Chris,

  This is possible, although undocumented -- as there is no "graceful" 
API function to grab the jqModal hash of an element. It is important to 
note that jqModal functionality is closely tied to "the hash" , and each 
jqModal-ized element ($(e).jqm()) is assigned a serial which points to 
its configuration object within "the hash". Conveniently, the hash is 
globally available via $.jqm.hash, and an jqModalized element's serial 
is available as an expando named "_jqm". Thus;

    var jqmElementHash = $.jqm.hash[$(jqmElement)[0]._jqm];

would correctly assign (and allow you to play with) the jqmElement's 
hash object.

  The hash object's properties are documented in the README, but as an 
example, here's how you would change a jqModal's onShow callback;

--

// accepts an element (either DOM or jQuery obj)
function changeOnShow(element, newCallback) {
    var h=$.jqm.hash[$(element)[0]._jqm];
    return h.c.onShow = newCallback;
}


Hope this helps and makes sense!

 NOTE; in *early* versions $.jqm.hash was available globally. In newer 
(r6-r9?), the hash was moved to the scope of the plugin. In r10 beta 
(available on plugin page), the hash is again globally available @ 
$.jqm.hash. Other minor improvements have been made, including Dimitry's 
compressable fixes.

  See; http://dev.jquery.com/jquery/jqModal/

~ Brice


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to