Skip to content

Commit ecd3a4f

Browse files
committed
bug fix: selecturl field dropdown do not work for new inline before they are saved.
1 parent 2f1044e commit ecd3a4f

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed
Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
(function($) {
22
var OTHER_CHOICE = '__other__'; //See
33
$(function(){
4-
var wrappers = $('.choice_with_other_wrapper');
5-
wrappers.each(function(){
6-
var select = $('select', this);
7-
var text_input = $('input', this);
8-
select.change(function(){
9-
if(select.val() == OTHER_CHOICE){
10-
;
11-
}else{
12-
text_input.val(select.val());
4+
$('body').delegate('.choice_with_other_wrapper select', 'change', function(e){
5+
var select = $(this)
6+
var text_input = $(this).parent().find('input')
7+
if(select.val() == OTHER_CHOICE){
8+
;
9+
}else{
10+
text_input.val(select.val());
11+
}
12+
});
13+
var text_input = $('input', this);
14+
$('body').delegate('.choice_with_other_wrapper input', 'keyup', function(e){
15+
var match = false;
16+
var text_input = $(this)
17+
var select = $(this).parent().find('select')
18+
$(select).find('option').each(function(){
19+
if($(this).attr('value') == text_input.val()){
20+
match = true;
1321
}
14-
});
15-
text_input.keyup(function(){
16-
var match = false;
17-
$(select).find('option').each(function(){
18-
if($(this).attr('value') == text_input.val()){
19-
match = true;
20-
}
21-
})
22-
if(!match){
23-
select.val(OTHER_CHOICE);
24-
}else{
25-
select.val(text_input.val());
26-
}
27-
});
28-
select.change();
22+
})
23+
if(!match){
24+
select.val(OTHER_CHOICE);
25+
}else{
26+
select.val(text_input.val());
27+
}
28+
})
29+
30+
$('.choice_with_other_wrapper').each(function(){
31+
$('select', this).change();
2932
})
33+
3034
})
31-
})(django.jQuery);
35+
})(django.jQuery);

0 commit comments

Comments
 (0)