-
-
Save alexander-ae/31cf169d6a88040109f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#{{ inline_admin_formset.formset.prefix }}-group").grp_inline({ | |
prefix: "{{ inline_admin_formset.formset.prefix }}", | |
//////////Función agregada para precargar y ejecutar el complemento tinyMCE | |
onBeforeAdded:function(form) { | |
if (tinyMCE != undefined) { | |
django.jQuery('.grp-empty-form').find('textarea').each(function() { | |
var tid = django.jQuery(this).attr("id"); | |
tinyMCE.execCommand("mceRemoveControl",false,tid); | |
}); | |
} | |
}, | |
///////////////////////////////////////////////////////////// | |
onAfterRemoved: function(inline) {}, | |
onAfterAdded: function(form) { | |
grappelli.reinitDateTimeFields(form); | |
grappelli.updateSelectFilter(form); | |
///////////// condicional que activa el complemento en un nuevo registro | |
if (tinyMCE != undefined) { | |
// re-initialise tinyMCE instances | |
deselector = tinyMCE.settings.editor_deselector; | |
django.jQuery(form).find('textarea:not(.'+deselector+')').each(function(k,v) { | |
var tid = django.jQuery(this).attr('id'); | |
tinyMCE.execCommand('mceAddControl', false, tid); | |
}); | |
} | |
/////////////////////////////////// | |
$.each(related_lookup_fields_fk, function() { | |
form.find("input[name^='" + prefix + "'][name$='-" + this + "']") | |
.grp_related_fk({lookup_url:"{% url 'grp_related_lookup' %}"}); | |
}); | |
$.each(related_lookup_fields_m2m, function() { | |
form.find("input[name^='" + prefix + "'][name$='-" + this + "']") | |
.grp_related_m2m({lookup_url:"{% url 'grp_m2m_lookup' %}"}); | |
}); | |
$.each(related_lookup_fields_generic, function() { | |
var content_type = this[0], | |
object_id = this[1]; | |
form.find("input[name^='" + prefix + "'][name$='-" + this[1] + "']") | |
.each(function() { | |
var i = $(this).attr("id").match(/-\d+-/); | |
if (i) { | |
var ct_id = "#id_" + prefix + i[0] + content_type, | |
obj_id = "#id_" + prefix + i[0] + object_id; | |
$(this).grp_related_generic({content_type:ct_id, object_id:obj_id, lookup_url:"{% url 'grp_related_lookup' %}"}); | |
} | |
}); | |
}); | |
$.each(autocomplete_fields_fk, function() { | |
form.find("input[name^='" + prefix + "'][name$='-" + this + "']") | |
.each(function() { | |
$(this).grp_autocomplete_fk({ | |
lookup_url:"{% url 'grp_related_lookup' %}", | |
autocomplete_lookup_url:"{% url 'grp_autocomplete_lookup' %}" | |
}); | |
}); | |
}); | |
$.each(autocomplete_fields_m2m, function() { | |
form.find("input[name^='" + prefix + "'][name$='-" + this + "']") | |
.each(function() { | |
$(this).grp_autocomplete_m2m({ | |
lookup_url:"{% url 'grp_m2m_lookup' %}", | |
autocomplete_lookup_url:"{% url 'grp_autocomplete_lookup' %}" | |
}); | |
}); | |
}); | |
$.each(autocomplete_fields_generic, function() { | |
var content_type = this[0], | |
object_id = this[1]; | |
form.find("input[name^='" + prefix + "'][name$='-" + this[1] + "']") | |
.each(function() { | |
var i = $(this).attr("id").match(/-\d+-/); | |
if (i) { | |
var ct_id = "#id_" + prefix + i[0] + content_type, | |
obj_id = "#id_" + prefix + i[0] + object_id; | |
$(this).grp_autocomplete_generic({ | |
content_type:ct_id, | |
object_id:obj_id, | |
lookup_url:"{% url 'grp_related_lookup' %}", | |
autocomplete_lookup_url:"{% url 'grp_autocomplete_lookup' %}" | |
}); | |
} | |
}); | |
}); | |
form.grp_collapsible(); | |
form.find(".grp-collapse").grp_collapsible(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment