Binded input loses focus on typing

5,266 views
Skip to first unread message

Flávio Atas Medeiros

unread,
Nov 4, 2012, 5:38:24 PM11/4/12
to ang...@googlegroups.com
Hi Guys.

I'm trying to solve this one but I can't find what I'm doing wrong: http://jsfiddle.net/KGu9n/2/

If you type something inside the input element you can only edit 1 char at a time (but you can paste anything).

Any ideas?

Thank you.

Peter Bacon Darwin

unread,
Nov 4, 2012, 5:43:19 PM11/4/12
to ang...@googlegroups.com
The problem is that with every change to the model object the ng-repeat regenerates the whole array and so blurs your input box.
What you need to do is wrap your strings in objects: http://jsfiddle.net/KGu9n/3/
Pete


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.
 
 

Flávio Atas Medeiros

unread,
Nov 4, 2012, 6:13:30 PM11/4/12
to ang...@googlegroups.com
I see. Thanks Pete!

sere...@gmail.com

unread,
Nov 6, 2012, 3:00:20 PM11/6/12
to ang...@googlegroups.com
hi.
and what if i have dynamic objects?


'<div class="taskBar-tags" scroll-height>' +
                                '<div class="board-tags taskBar-tagsGroup" ' +
                                'ng-repeat="(groupLabel, tags) in currentTask.tags">' +
                                     '<h4 class="board-label">{{makeGroupTagsLabel(groupLabel)}}:</h4>' +
                                     '<input class="edit" ng-model="currentTask.tags[groupLabel]" ng-change="currentTask.showFields()" ng-list/>' +
                                '</div>' +
                            '</div>' +

where currentTask changes every time i click on particular element...

Peter Bacon Darwin

unread,
Nov 7, 2012, 6:07:35 AM11/7/12
to ang...@googlegroups.com
What is your question?

Jonathan Anthony

unread,
Apr 2, 2014, 5:19:44 PM4/2/14
to ang...@googlegroups.com
Guys very late to this - I had a similar problem with the input blurring on each character press "track by $index" solved it for me  e.g. 

<div  ng-repeat="source in widget_data.widget track by $index">
            <div class="form-group"><label>Name</label> <input class="form-control" type="text" ng-model="source.content_type.metadata.name"></div>
        </div>

Igwe Kalu

unread,
Oct 2, 2014, 4:16:28 AM10/2/14
to ang...@googlegroups.com
Hi Pete,

I'm having the same experience - I find it weird because everything was OK earlier before this quirky behaviour started to manifest.
This happens even as my my model is a string property of an object.

Do you know why it should behave this way?
Reply all
Reply to author
Forward
0 new messages