I have a weird bug with the TextField
that I don't understand. This is the first time I am working with TextField
, before I was using {{input}}
instead, but for the sake of form validations etc I needed to change.
My problem is that I have two TextField
and when I enter something in the first one, the second one also has the value.. If I enter 'Hello' in the first, the second will also filled with 'Hello', like they are linked somehow..
This is my template login.hbs:
<div class="form-group">
<label class="control-label hidden">Mandatory field</label>
{{view "input" type="text" classNames="form-control" value=username placeholder="Please enter username"}}
</div>
<div class="form-group">
<label class="control-label hidden">Mandatory field</label>
{{view "input" type="password" classNames="form-control" value=username placeholder="Please enter password"}}
</div>
My views/login.js :
export default Ember.View.extend({
actions: {
submit: function() {
this.get('controller').send('login');
}
}
});
My views/input.js This one is just some DOM check.
export default Ember.TextField.extend({
focusOut: function( e ) {
var $tag = Ember.$(e.currentTarget);
if (!$tag.val()) {
if(!$tag.parent().hasClass('has-error')) {
$tag.parent().find('.control-label').removeClass('hidden');
$tag.parent().addClass('has-error');
}
} else {
if($tag.parent().hasClass('has-error')) {
$tag.parent().find('.control-label').addClass('hidden');
$tag.parent().removeClass('has-error');
}
}
}
});
Did I do something wrong ??
Thanks.
Aucun commentaire:
Enregistrer un commentaire