Sha256: 75e4bda385d729e1c06129f1bc9d056f3f5e35bed6a8758ea11c9d20e3175cec

Contents?: true

Size: 1.34 KB

Versions: 38

Compression:

Stored size: 1.34 KB

Contents

function new_record(id,name,model_name){
	model_name = name.split("[")
	class_name = model_name[0]
	model_name = model_name[model_name.length - 1].split("_id]")[0];
	
	$('#modal_new_record').attr("class","modal inmodal")
	$('#modal_new_record').addClass(model_name);

	var model_target = "#modal_new_record." + model_name;
	
	var url = link_to("/crud/" + class_name + "/new.js", {"render": "modal", "attribute": model_name});
	var jqxhr = $.ajax(url)
	.done(function(result) {
		$(model_target).attr('data-source',id);
		$(model_target).attr('data-saved','false');
		$(model_target).on('hidden.bs.modal', function (e) {
			if($(model_target).attr('data-saved') == 'true'){
				var entity_desc = $(model_target).attr('data-entity-name')
				var entity_id   = $(model_target).attr('data-entity-id')
				$('#' + id).append($('<option>', {
					value: entity_id,
					text: entity_desc,
					selected: 'selected'
				}));
				if($('#' + id).hasClass("chosen")){
					$('#' + id).trigger("chosen:updated");
				}
				$(model_target).attr('data-saved','false');
				$(model_target).attr('data-entity-name','')
				$(model_target).attr('data-entity-id','')
			}
		})
		$(model_target + ' .modal-body').html(result);
		$(model_target).modal('show');
		$('.modal-backdrop').appendTo("body");
		if(window.hasOwnProperty("atualiza_campos_crud")){
			atualiza_campos_crud();
		}
	});
}

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
templus_models-3.0.21 app/assets/javascripts/raro_crud.js
templus_models-3.0.20 app/assets/javascripts/raro_crud.js
templus_models-3.0.19 app/assets/javascripts/raro_crud.js
templus_models-3.0.17 app/assets/javascripts/raro_crud.js
templus_models-2.0.16 app/assets/javascripts/raro_crud.js
templus_models-1.6.9 app/assets/javascripts/raro_crud.js
templus_models-2.0.15 app/assets/javascripts/raro_crud.js
templus_models-3.0.14 app/assets/javascripts/raro_crud.js
templus_models-2.0.14 app/assets/javascripts/raro_crud.js
templus_models-2.0.12 app/assets/javascripts/raro_crud.js
templus_models-3.0.13 app/assets/javascripts/raro_crud.js
templus_models-3.0.12 app/assets/javascripts/raro_crud.js
templus_models-2.0.11 app/assets/javascripts/raro_crud.js
templus_models-2.0.9 app/assets/javascripts/raro_crud.js
templus_models-2.0.8 app/assets/javascripts/raro_crud.js
templus_models-3.0.10 app/assets/javascripts/raro_crud.js
templus_models-1.6.8 app/assets/javascripts/raro_crud.js
templus_models-1.6.7 app/assets/javascripts/raro_crud.js
templus_models-3.0.9 app/assets/javascripts/raro_crud.js
templus_models-2.0.7 app/assets/javascripts/raro_crud.js