Browse Source

fix links not updating after changing variables

Marcus Efraimsson 7 năm trước cách đây
mục cha
commit
5e4d6958d6

+ 9 - 8
public/app/features/dashlinks/module.ts

@@ -41,20 +41,20 @@ function dashLink($compile, $sanitize, linkSrv) {
       elem.html(template);
       elem.html(template);
       $compile(elem.contents())(scope);
       $compile(elem.contents())(scope);
 
 
-      var anchor = elem.find('a');
-      var icon = elem.find('i');
-      var span = elem.find('span');
-
       function update() {
       function update() {
         var linkInfo = linkSrv.getAnchorInfo(link);
         var linkInfo = linkSrv.getAnchorInfo(link);
+
+        const anchor = elem.find('a');
+        const span = elem.find('span');
         span.text(linkInfo.title);
         span.text(linkInfo.title);
+
         if (!link.asDropdown) {
         if (!link.asDropdown) {
           anchor.attr('href', linkInfo.href);
           anchor.attr('href', linkInfo.href);
           sanitizeAnchor();
           sanitizeAnchor();
         }
         }
-        elem.find('a').attr('data-placement', 'bottom');
+        anchor.attr('data-placement', 'bottom');
         // tooltip
         // tooltip
-        elem.find('a').tooltip({
+        anchor.tooltip({
           title: $sanitize(scope.link.tooltip),
           title: $sanitize(scope.link.tooltip),
           html: true,
           html: true,
           container: 'body',
           container: 'body',
@@ -62,12 +62,13 @@ function dashLink($compile, $sanitize, linkSrv) {
       }
       }
 
 
       function sanitizeAnchor() {
       function sanitizeAnchor() {
+        const anchor = elem.find('a');
         const anchorSanitized = $sanitize(anchor.parent().html());
         const anchorSanitized = $sanitize(anchor.parent().html());
         anchor.parent().html(anchorSanitized);
         anchor.parent().html(anchorSanitized);
       }
       }
 
 
-      icon.attr('class', 'fa fa-fw ' + scope.link.icon);
-      anchor.attr('target', scope.link.target);
+      elem.find('i').attr('class', 'fa fa-fw ' + scope.link.icon);
+      elem.find('a').attr('target', scope.link.target);
 
 
       // fix for menus on the far right
       // fix for menus on the far right
       if (link.asDropdown && scope.$last) {
       if (link.asDropdown && scope.$last) {