Base solution for your next web application
Open Closed

Event when completly loaded #2518


User avatar
0
jamsecgmbh created

Hi, I have to set the focus on an input element that I identify. I am using SPA with Angular 1. I am able to identify it and and i am able to set the focus - but the finally part of the event listener of the service method seems to fire to early to use my method, cause the focus is not set.

I have tried to use the "$scope.$on('$viewContentLoaded', function ()" that is contained in some views, but without luck - the function content will not be called.

Do you have a hint for me, how I can use event listeners that can call my function when everything is in place and loaded? Thank you very much!


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    The project contains a directive for this <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/blob/dev/src/MyCompanyName.AbpZeroTemplate.Web/App/common/directives/autoFocus.js">https://github.com/aspnetzero/aspnet-ze ... toFocus.js</a>.

    You can use it like this.

    <input type="text" autoFocus />
    

    If you need a common need for running javascript code when the content is completely loaded, you can follow a similar approach to this directive.

    IF you want to run jquery on elements, you can use ui-jq directive which is also included in the project.