admin管理员组文章数量:1291121
Thanks in advance for your help. I'm using this tagmanager in my web application. The jQuery function works FINE until this
<input type="text" name="tags" placeholder="Tags" class="tagsManager" />
Is placed under
ng-repeat = "(key,val) in client_proj"
Here is a short snippet of the code
<div class="accordion-group" ng-repeat="(key,val) in client_proj"><!--For Every Project in Project List-->
<div class="accordion-heading" style="background-color:#EFF8FB">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#mainAccordion" href="#{{val.id}}" ng-click="disableEditor()">
<div align="center">{{val.title}}</div>
</a>
</div>
<div id="{{val.id}}" class="accordion-body collapse">
<div class="accordion-inner" style="font-size:12px; background-color:white">
<strong>Technologies Exposure:</strong><br/>
<div ng-hide="editorEnabled">{{val.exposure}}</div>
<div ng-show="editorEnabled">
<textarea ng-show="editorEnabled" class="span12" ng-model="val.exposure" rows="12" style="resize:vertical"></textarea>
<input type="text" name="tags" placeholder="Tags" class="tagsManager" />
It appears as a normal input without doing any of its functions like creating a new tag after pressing, or enter.
Can anyone tell me what's happening?
Thanks in advance for your help. I'm using this tagmanager in my web application. The jQuery function works FINE until this
<input type="text" name="tags" placeholder="Tags" class="tagsManager" />
Is placed under
ng-repeat = "(key,val) in client_proj"
Here is a short snippet of the code
<div class="accordion-group" ng-repeat="(key,val) in client_proj"><!--For Every Project in Project List-->
<div class="accordion-heading" style="background-color:#EFF8FB">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#mainAccordion" href="#{{val.id}}" ng-click="disableEditor()">
<div align="center">{{val.title}}</div>
</a>
</div>
<div id="{{val.id}}" class="accordion-body collapse">
<div class="accordion-inner" style="font-size:12px; background-color:white">
<strong>Technologies Exposure:</strong><br/>
<div ng-hide="editorEnabled">{{val.exposure}}</div>
<div ng-show="editorEnabled">
<textarea ng-show="editorEnabled" class="span12" ng-model="val.exposure" rows="12" style="resize:vertical"></textarea>
<input type="text" name="tags" placeholder="Tags" class="tagsManager" />
It appears as a normal input without doing any of its functions like creating a new tag after pressing, or enter.
Can anyone tell me what's happening?
Share Improve this question edited Jul 13, 2016 at 7:56 Nhan 3,9056 gold badges34 silver badges40 bronze badges asked Mar 3, 2013 at 8:47 user1166085user1166085 6273 gold badges13 silver badges25 bronze badges 3- I assume it's because the content of ng-repeat is not present when the jQuery plugin runs. My suggestion is that you use a custom directive. I feel like anytime you need to write specific scaffolding html/css a directive is better suited. You have better control over rendering + behaviour – Liviu T. Commented Mar 3, 2013 at 10:47
- does it mean that i can't use the jquery tagmanager but instead have to create my own? im confused. – user1166085 Commented Mar 3, 2013 at 12:37
- initialize the jQuery plugin from within the suggested directive. – charlietfl Commented Mar 3, 2013 at 14:04
1 Answer
Reset to default 101.Create a custom directive that acts as a wrapper for your jQuery plugin:
angular.module('<YOUR APP OR MODULE>').directive('tagsManager', function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element.tagsManager();
//whatever other logic would go here
}
};
});
Then remove the automatic initialization of tabsManager (something like $('<SELECTOR>').tagsManager();
or jQuery('<SELECTOR>').tagsManager();
) from your script
Ultimately, in your ng-repeat, add the directive to the input element (optionally add other attributes -- you might have to program the behavior for these attributes within your directive -- if they are required)
<input tags-manager>
This will make AngularJS initialize tabsManager on your inputs (via the custom directive) after they are rendered in the DOM.
Makes sense?
本文标签: javascriptexecuting jQuery function after ngrepeatStack Overflow
版权声明:本文标题:javascript - executing jQuery function after ng-repeat - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741518836a2383057.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论