$items[] = "packages/jquery/plugins/jquery.tableHeader.js";
$items[] = "packages/jquery/plugins/jquery.menu.min.js";
$items[] = "css/civicrmNavigation.css";
- $items[] = "packages/jquery/plugins/jquery.jeditable.min.js";
$items[] = "packages/jquery/plugins/jquery.notify.min.js";
- $items[] = "js/jquery/jquery.crmeditable.js";
}
// JS for multilingual installations
var script = document.createElement('script');
scriptsLoaded[url] = $.Deferred();
script.onload = function () {
+ if (window.jQuery === CRM.$ && CRM.CMSjQuery) {
+ window.jQuery = CRM.CMSjQuery;
+ }
scriptsLoaded[url].resolve();
};
+ // Make jQuery global available while script is loading
+ if (window.jQuery !== CRM.$) {
+ CRM.CMSjQuery = window.jQuery;
+ window.jQuery = CRM.$;
+ }
script.src = url;
document.getElementsByTagName("head")[0].appendChild(script);
}
$('.crm-form-text[data-crm-datepicker]', e.target).each(function() {
$(this).crmDatepicker($(this).data('crmDatepicker'));
});
+ $('.crm-editable', e.target).not('thead *').each(function() {
+ var $el = $(this);
+ CRM.loadScript(CRM.config.resourceBase + 'js/jquery/jquery.crmEditable.js').done(function() {
+ $el.crmEditable();
+ });
+ });
// Cache Form Input initial values
$('form[data-warn-changes] :input', e.target).each(function() {
$(this).data('crm-initial-value', $(this).is(':checkbox, :radio') ? $(this).prop('checked') : $(this).val());
}
$i.addClass('crm-editable-enabled');
- $i.editable(function(value, settings) {
+ function callback(value, settings) {
$i.addClass('crm-editable-saving');
var
info = $i.crmEditableEntity(),
.fail(function(data) {
editableSettings.error.call($el[0], info.entity, info.field, value, data);
});
- }, settings);
+ }
+
+ CRM.loadScript(CRM.config.resourceBase + 'packages/jquery/plugins/jquery.jeditable.min.js').done(function() {
+ $i.editable(callback, settings);
+ });
// CRM-15759 - Workaround broken textarea handling in jeditable 1.7.1
$i.click(function() {
});
};
- $(document).on('crmLoad', function(e) {
- $('.crm-editable', e.target).not('thead *').crmEditable();
- });
-
})(jQuery, CRM._);
"oLanguage": {"sEmptyTable": noRecordFoundMsg,
"sZeroRecords": noRecordFoundMsg },
"fnDrawCallback": function () {
- // FIXME: trigger crmLoad and crmEditable would happen automatically
- $('.crm-editable').crmEditable();
+ $(this).trigger('crmLoad');
},
"fnRowCallback": function (nRow, aData, iDisplayIndex) {
//insert the id for each row for enable/disable.
"oLanguage":{"sEmptyTable" : noRecordFoundMsg,
"sZeroRecords" : noRecordFoundMsg },
"fnDrawCallback": function() {
- // FIXME: trigger crmLoad and crmEditable would happen automatically
- CRM.$('.crm-editable').crmEditable();
+ $(this).trigger('crmLoad');
},
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
"oLanguage":{"sEmptyTable" : noRecordFoundMsg,
"sZeroRecords" : noRecordFoundMsg },
"fnDrawCallback": function() {
- // FIXME: trigger crmLoad and crmEditable would happen automatically
- CRM.$('.crm-editable').crmEditable();
+ $(this).trigger('crmLoad');
},
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
// Crm-editable
return nRow;
},
"fnDrawCallback": function() {
- // FIXME: trigger crmLoad and crmEditable would happen automatically
- $('.crm-editable').crmEditable();
+ $(this).trigger('crmLoad');
},
"fnServerData": function ( sSource, aoData, fnCallback ) {
return nRow;
},
"fnDrawCallback": function(oSettings) {
- // FIXME: trigger crmLoad and crmEditable would happen automatically
- $('.crm-editable', '#crm-batch-selector-{/literal}{$batchStatus}{literal}').crmEditable();
+ $(this).trigger('crmLoad');
$("#toggleSelect").prop('checked', false);
if (checkedRows.length) {
$(checkedRows.join(',')).prop('checked', true).change();
}
function enableDisable() {
- $a = $(this);
$row = $a.closest('.crm-entity');
info = $a.crmEditableEntity();
fieldLabel = info.label || info.title || info.display_name || info.name || {/literal}'{ts escape="js"}Record{/ts}'{literal};
} else {
save();
}
- return false;
}
// Because this is an inline script it may get added to the document more than once, so remove handler before adding
$('body')
.off('.crmEnableDisable')
- .on('click.crmEnableDisable', '.action-item.crm-enable-disable', enableDisable);
+ .on('click.crmEnableDisable', '.action-item.crm-enable-disable', function(e) {
+ e.preventDefault();
+ $a = $(this);
+ CRM.loadScript(CRM.config.resourceBase + 'js/jquery/jquery.crmEditable.js').done(enableDisable);
+ });
});
</script>
{/literal}