Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mihail 39 posts 142 karma points
    Apr 27, 2016 @ 06:44
    Mihail
    0

    Show tab based on location.hash value

    Hi,

    I have an url like: http://localhost:1188/umbraco#/content/content/edit/1074#tab19

    I want with #tab19 to activate the third tab (mean to show the third tab).

    I tried:

    1. I edited page edit.html (I added after-render="loadTabByUrl")

      <umb-tabs-content class="form-horizontal" view="true" after-render="loadTabByUrl">
                 <umb-tab id="tab{{tab.id}}" ng-repeat="tab in content.tabs" rel="{{tab.id}}">
      
      
      
                &lt;umb-property ng-repeat="property in tab.properties" property="property"&gt;
                   &lt;umb-editor model="property"&gt;&lt;/umb-editor&gt;
                &lt;/umb-property&gt;
      
      
             &lt;/umb-tab&gt;
      
      </umb-tabs-content>
    2. I add the following code to umbraco.directives.js

      angular.module("umbraco.directives").directive("afterRender", [
           '$timeout', function($timeout) {
             var def = {
              restrict: 'A',
              terminal: true,
              transclude: false,
              link: function (scope, element, attrs) {
                 $timeout(scope.$eval(attrs.afterRender), 0); //Calling a scoped method
              }
           };
           return def;
        }
      ]);
      
    3. And umbraco.controllers.js

      $scope.loadTabByUrl = function () {
        if (!location.hash) {
           return;
        }
      
      
         if (location.hash.split("#").length <= 1) {
          return;
        } 
      
      
         var tabId = location.hash.substring(location.hash.lastIndexOf("hash") + 1);
         if (!tabId) {
            return;
          }
      
      
      
      $("a[href='" + tabId + "']").tab("show");
      
      }

    But the rendered edit page doesn't show the after-render="loadTabByUrl", somehow look like that I edited the wrong template but I got it from ~/Umbraco/Views/content/edit.html, this is the one

    How to make it work ?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies