|
|
|
|
@ -31,50 +31,18 @@
|
|
|
|
|
var modalFormScript = function (formitem,repeat) {
|
|
|
|
|
$('#mod_edit').modal({keyboard: false, backdrop: 'static'});
|
|
|
|
|
$('.mod_close').click(function(event) {
|
|
|
|
|
[%IF m.close_target_direct%]
|
|
|
|
|
[%m.close_target_direct%]
|
|
|
|
|
[%ELSIF m.ajax_load%]
|
|
|
|
|
$('#mod_edit').modal('hide');
|
|
|
|
|
$('#mod_edit').parent('div').html('');
|
|
|
|
|
[%ELSE%]
|
|
|
|
|
console.log("redirecting to [% m.close_target ? m.close_target : c.uri_for() %]");
|
|
|
|
|
window.location.href="[% m.close_target ? m.close_target : c.uri_for() %]";
|
|
|
|
|
[%END%]
|
|
|
|
|
});
|
|
|
|
|
[%IF m.ajax_load%]
|
|
|
|
|
$('#mod_edit script').each(function( key, value ) {
|
|
|
|
|
eval(value.innerHTML);
|
|
|
|
|
});
|
|
|
|
|
[%END%]
|
|
|
|
|
|
|
|
|
|
// on clicking a button within the form, add a hidden field "submitid"
|
|
|
|
|
// determining the name of the button being clicked
|
|
|
|
|
$('input[type=button]').click(function() {
|
|
|
|
|
$('#mod_edit form').on("click", "input[type=button]", function() {
|
|
|
|
|
$(this).parents('form').find('#submitid').attr('value', $(this).attr('name'));
|
|
|
|
|
[%IF !m.ajax_load%]
|
|
|
|
|
$(this).parents('form').submit();
|
|
|
|
|
[%ELSE%]
|
|
|
|
|
$('#mod_edit').modal('hide');
|
|
|
|
|
processModalFormAjax($(this).parents('form'),function(status,form){
|
|
|
|
|
//alert('in callback: status='+status);
|
|
|
|
|
if( status == 'error' ){
|
|
|
|
|
modalFormScript(formitem);
|
|
|
|
|
}
|
|
|
|
|
if( status != 'error' ){
|
|
|
|
|
//form object is necessary to compose uri for refresh
|
|
|
|
|
[%IF m.ajax_list_refresh%]
|
|
|
|
|
refreshAjaxList( '[%m.ajax_list_refresh%]', form );
|
|
|
|
|
[%END%]
|
|
|
|
|
$('#mod_edit').parent('div').html('');
|
|
|
|
|
}
|
|
|
|
|
[%m.ajax_callback%]
|
|
|
|
|
});
|
|
|
|
|
[%END%]
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
[%IF !m.ajax_load%]$(modalFormScript);[%ELSE%]
|
|
|
|
|
//$('#'+$(this).parents('form').id()+' :input:enabled:visible:first').focus();
|
|
|
|
|
[%END%]
|
|
|
|
|
$(modalFormScript);
|
|
|
|
|
</script>
|
|
|
|
|
[% END -%]
|
|
|
|
|
|
|
|
|
|
|