Adding new item to list and managing focus

139 views
Skip to first unread message

Ed Thompson

unread,
Jan 2, 2014, 9:59:48 AM1/2/14
to ang...@googlegroups.com
I have a simple(?) Angularjs repeat list that when I add a new item to the list, displays the new item as I expect.

    <tr class='claimrow' data-ng-repeat='c in dp.claims'>
        <td>
            <div contentedittable=true>some data</div>
       </td>
...
    </tr>

So adding an item to dp.claims adds a new row to the table.

The issue is, I want to give the div in the first cell of the NEW row focus, but since the rendering of the row is handled separate from me adding it to the list, I don't know how to approach this challenge.

is there and angular 'way'?


Sander Elias

unread,
Jan 2, 2014, 12:06:17 PM1/2/14
to ang...@googlegroups.com
Hi Ed,

As you know which row has to be selected, you can create an small directive that put the focus on the first 'input'
If you put your sample up in a plunk or fiddle, I will happily take a stab at it!

Regards
Sander

Ed Thompson

unread,
Jan 2, 2014, 1:34:11 PM1/2/14
to ang...@googlegroups.com
I know the row, so I could use DOM functions, but I don't know WHEN since I don't control the rendering.

I'll try to get an example


--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/L-xu-8IQq9c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Ed Thompson

unread,
Jan 2, 2014, 2:08:51 PM1/2/14
to ang...@googlegroups.com

Sander Elias

unread,
Jan 2, 2014, 2:22:54 PM1/2/14
to ang...@googlegroups.com
Hi Ed,

here is a sample on how to solve this!
Is this enough to get you started?

Regards
Sander

Ed Thompson

unread,
Jan 2, 2014, 3:00:10 PM1/2/14
to ang...@googlegroups.com
It is, thanks Sander.


--
Reply all
Reply to author
Forward
0 new messages