If you load a form onto a web2py page via AJAX, it doesn't get the enhancements
from web2py_ajax_init().
I've included a modified web2py_ajax_init that accepts an optional parent
selector to provide some scope to web2py_ajax_init. In this way if you load a
form onto a page, you can call web2py_ajax_init on that specific form to give
it the enhancements, without effecting every other form on the page.
I've included the modified function here as it may be useful to others in the
future.
An alternative approach may be to bind events using jQuery.live(), so that you
don't have to explicitly call web2py_ajax_init() every time you load a form.
--------
function web2py_ajax_init(parent) {
var find = function(selector) {
if (parent)
return $(parent).find(selector);
else
return jQuery(selector);
}
find('.hidden').hide();
find('.error').hide().slideDown('slow');
find('.flash').click(function() { find(this).fadeOut('slow'); return false;
});
// find('input[type=submit]').click(function(){var
t=find(this);t.hide();t.after('<input class="submit_disabled"
disabled="disabled" type="submit" name="'+t.attr("name")+'_dummy"
value="'+t.val()+'">')});
find('input.integer').keyup(function(){this.value=this.value.reverse().replace(/[^0-9\-]|\-(?=.)/g,'').reverse();});
find('input.double,input.decimal').keyup(function(){this.value=this.value.reverse().replace(/[^0-9\-\.]|[\-](?=.)|[\.](?=[0-9]*[\.])/g,'').reverse();});
find("input[type='checkbox'].delete").each(function(){find(this).click(function()
{ if(this.checked) if(!confirm("{{=T('Sure you want to delete this
object?')}}")) this.checked=false; });});
try {find("input.date").focus(function() {Calendar.setup({
inputField:this.id, ifFormat:"{{=T('%Y-%m-%d')}}", showsTime:false
}); }); } catch(e) {};
try { find("input.datetime").focus( function() {Calendar.setup({
inputField:this.id, ifFormat:"{{=T('%Y-%m-%d %H:%M:%S')}}", showsTime:
true,timeFormat: "24"
}); }); } catch(e) {};
try { find("input.time").timeEntry(); } catch(e) {};
};
---------------
This communication, including any attachments, does not necessarily represent
official policy of Seccuris Inc.
Please see http://www.seccuris.com/Contact-PrivacyPolicy.htm for further
details about Seccuris Inc.'s Privacy Policy.
If you have received this communication in error, please notify Seccuris Inc.
at [email protected] or at 1-866-644-8442.