Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamic Focus
Message
From
26/07/2014 03:53:53
 
General information
Forum:
Javascript
Category:
Other
Title:
Miscellaneous
Thread ID:
01604694
Message ID:
01604713
Views:
56
This message has been marked as a message which has helped to the initial question of the thread.
>Hi everybody,
>
>This should be easy, I think, but I am not exactly sure how to make it.
>
>Here are my two controls on the form:
>
>
><div class="controls">
>                    <div class="col-lg-9">
>                        <input type="text"
>                               name="nickname"
>                               id="nickname"
>                               ng-model="currentDynamicRule.nickname"
>                               class="form-control"
>                               ng-disabled="!isNew"
>                               placeholder="Nickname"
>                               required
>                               ng-maxlength="10"
>                                />
>                        <div class="field-validation-error">
>                            <span ng-show="form.nickName.$error.required && form.nickName.$dirty">Nickname is required.</span>
>                            <span ng-show="form.nickName.$error.maxlength && form.nickName.$dirty">Nickname cannot exceed 10 characters.</span>
>                        </div>
>                    </div>
>                </div>
>            </div>
>
>            <div class="form-group">
>                <div class="control-label col-lg-3">
>                    <label title="Description">Description:</label>
>                </div>
>                <div class="controls">
>                    <div class="col-lg-9">
>                        <input type="text" name="descrip" id="descrip" ng-model="currentDynamicRule.descrip" class="form-control"
>                               placeholder="Description" required ng-maxlength="30"
>                               sm-focus />
>                        <div class="field-validation-error">
>                            <span ng-show="form.descrip.$error.required && form.descrip.$dirty">Description is required.</span>
>                            <span ng-show="form.descrip.$error.maxlength && form.descrip.$dirty">Description cannot exceed 30 characters.</span>
>                        </div>
>                    </div>
>                </div>
>            </div>
>
>So, I have nickname and Description. When I am in the New Mode, the first control should be nickname and it should have focus, otherwise it should be description. Right now I put the focus on the Description control as you see (sm-focus).
>
>How can I make this conditional the same was as ng-disabled?
>
>UPDATE. sm-focus is angularjs directive and it has this code:
>
>(function () {
>    'use strict';
>
>    var app = angular.module('sysMgrApp');
>
>    app.directive('smFocus', [ '$timeout', function ($timeout) {
>        return {
>            restrict: 'A',            
>            link: function (scope, element) {
>
>                scope.$on('sm:focus', function () {
>                    $timeout(function () {
>                        if (element[0].disabled = "false")
>                            element[0].focus();
>                    }, 10);
>                });
>            }
>        };
>    }]);
>})();
>
>
>
>
>I just added this line into it
>
> if (element[0].disabled = "false")
>
>Not sure, if correct at all or not. Will try it out.
>
>UPDATE 2. Adding this line made control show disabled, so I removed it from the directive.
>
>Thanks in advance.

= is assignment. Use ===
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform