1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- //Initialisation du composant d'export modèle
- function init_components_export_model(input){
- var cbLoaded = input.attr('data-callback') ? input.attr('data-callback') : '';
- var cbParams = input.attr('data-callback-parameters') ? input.attr('data-callback-parameters').split(',') : [];
- var parameters = JSON.parse(input.attr('data-parameters'));
- $(document).ready(function(e){
- input.on('click', function(e){
- $.ajax({
- type: 'GET',
- url: 'plugin/export/modal.export.model.php',
- async: true,
- success : function(modal){
- if(cbLoaded) window[cbLoaded].apply(null,cbParams);
- }
- }).done(function(modalContent){
- if(!$('#export-modal').length)
- $('body').append(modalContent);
- var modal = $('#export-modal');
- reset_inputs(modal);
- $.action({
- action: 'export_exportmodel_search',
- params: parameters
- }, function(r){
- if(r.rows){
- var defaultExport = input.attr('data-default');
- var selectExport = $('#exportModel');
- selectExport.find('option').remove();
- $.each(r.rows,function(i, option){
- var opt = $('<option value="'+option.id+'">'+option.label+' - '+option.description+'</option>');
- if(defaultExport && defaultExport.length && option.slug === defaultExport) opt.attr('selected', true);
- selectExport.append(opt);
- });
- }
- $('#exportmodel-form').attr('data-parameters', JSON.stringify(parameters));
- if($('#exportModel > option').length == 1){
- export_exportmodel_export();
- return;
- }
- init_components($('#export-modal'));
- modal.modal('show');
- });
- });
- });
- });
- }
|