try and deal with widget value nonsense
This commit is contained in:
parent
e766fdc858
commit
16e296d9f4
|
@ -39,7 +39,9 @@ class AutocompleteAddWidget(forms.Select):
|
|||
if choice[0] == id:
|
||||
return choice[1]
|
||||
return ''
|
||||
|
||||
|
||||
#import pdb
|
||||
#pdb.set_trace()
|
||||
ctx = super(AutocompleteAddWidget, self).get_context(name, value, attrs)
|
||||
if value:
|
||||
ctx['title'] = get_matched_choice_title(self.choices, value)
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<input type="hidden" id="id_{{name}}" name="{{name}}" data-ctype="{{ ctype.id }}" class="select2class" data-id="{% if value %}{{ value }} {% endif %}" data-title="{% if title %} {{ title }} {% endif %}" style="width:600px;" /> <a href="/popup_form/{{ ctype.id }}" class="popup_add_btn" title="Add new" id="add_{{name}}" onclick="return showAddAnotherPopup(this);">+</a>
|
||||
<input type="hidden" id="id_{{name}}" name="{{name}}" data-ctype="{{ ctype.id }}" class="select2class" data-id="{% if value %}{% for v in value %}{{v}}{% endfor %}{% endif %}" data-title="{% if title %}{{ title }}{% endif %}" style="width:600px;" value="" /> <a href="/popup_form/{{ ctype.id }}" class="popup_add_btn" title="Add new" id="add_{{name}}" onclick="return showAddAnotherPopup(this);">+</a>
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ $(function(){
|
|||
}
|
||||
});
|
||||
var id = $this.attr("data-id");
|
||||
console.log(id);
|
||||
if ($.trim(id) !== '') {
|
||||
var title = $this.attr("data-title");
|
||||
$this.select2("val", {'id': id, 'title': title});
|
||||
|
|
Loading…
Reference in New Issue
Block a user