Skip to content

Commit 6817e13

Browse files
committed
More width for text control. Show both controls at the same time and have them update each other.
1 parent 3ccc29d commit 6817e13

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

ixxy_url_field/choice_with_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ChoiceWithOtherWidget(forms.MultiWidget):
99
def __init__(self, choices, attrs=None):
1010
widgets = [
1111
forms.Select(choices=choices),
12-
forms.TextInput
12+
forms.TextInput(attrs={'size':'80'})
1313
]
1414
self.choices = choices
1515
super(ChoiceWithOtherWidget, self).__init__(widgets, attrs=attrs)

ixxy_url_field/static/admin/choice_with_other.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
var select = $('select', this);
77
var text_input = $('input', this);
88
select.change(function(){
9-
if(!(select.val() == OTHER_CHOICE)){
10-
text_input.hide();
11-
}else{
12-
text_input.show();
13-
}
14-
})
9+
text_input.val(select.val());
10+
// if(!(select.val() == OTHER_CHOICE)){
11+
// text_input.show();
12+
// }else{
13+
// text_input.show();
14+
// }
15+
});
16+
text_input.keyup(function(){
17+
select.val(text_input.val());
18+
});
1519
select.change();
1620
})
1721
})

0 commit comments

Comments
 (0)