Saturday 15 March 2014

Disable all child elements using angularjs directive -



Disable all child elements using angularjs directive -

i have created directive disable of selected kid elements :

app.directive('noedisable', function () { var linkfunction = function (scope, element, attributes) { scope.text = attributes["=noedisable"]; if (scope.text == 'true') { $(element).find('input,button,a').attr("disabled", true); } }; homecoming { link: linkfunction }; });

and work example: <div noe-disable="true"> ... </div>. problem of kid elements load later, illustration after ajax phone call or when have angularjs directive within parent element add together kid elements parent, wont disabled !!! how can deal problem ?

you can utilize fieldset.

wrap fields in fieldset , utilize ng-disabled like:

<fieldset ng-disabled="shoulddisabled"> ... inputs ... </fieldset>

it automatically disable inputs within fieldset.

angularjs angularjs-directive

No comments:

Post a Comment