Copied to clipboard

Flag this post as spam?

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


  • Mathias Andreasen 43 posts 155 karma points
    Jul 14, 2017 @ 08:46
    Mathias Andreasen
    1

    Custom Section, Custom Plugin, Controller is not a function.....

    Hello,

    I've just created a custom section, but my plugin doesn't seem to work. When I open my section and click on my TreeNode I get the following error:

    angular.min.js?cdv=1901956542:63 Error: Argument 'Scandbio.EditController' is not a function, got undefined
    

    I found a thread on this forum where someone had a similiar issue, the solution there was to make sure the package.manifest file isn't saved with a BOM flag, I've done this and made sure it's saved as UTF-8.

    My package.manifest

    {
    propertyEditors: [
        {
            alias: "Pdb.ECommerce",
            name: "Pdb - ECommerce",
            editor: {
                view: "~/App_Plugins/Scandbio/backoffice/edit.html"
            }
        }
    ],
    javascript: [
        "~/App_Plugins/Scandbio/backoffice/ecommerce/resources.js",
        "~/App_Plugins/Scandbio/backoffice/ecommerce/edit.controller.js",
        "~/App_Plugins/Scandbio/backoffice/ecommerce/dialog.add.controller.js",
        "~/App_Plugins/Scandbio/backoffice/ecommerce/dialog.edit.controller.js"
    ]}
    

    edit.html

    <div ng-controller="Scandbio.EditController" class="ecommerce">
       <!-- STUFF -->
    </div>
    

    edit.controller.js

    angular.module("umbraco").controller("Scandbio.EditController", function ($scope, notificationsService, dialogService, assetsService, ecommerceResource) {
    // STUFF
    }
    

    Help me Our.Umbraco-users, you are my only hope

  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    Jul 14, 2017 @ 08:59
    Alex Skrypnyk
    0

    Hi Mathias

    Did you clear ClientDependency cache?

    Can you remove AppData/TEMP/ClientDependency and AppData/TEMP/PluginCache folders?

    Thanks,

    Alex

  • Mathias Andreasen 43 posts 155 karma points
    Jul 14, 2017 @ 09:02
    Mathias Andreasen
    0

    Hello Alex,

    I tried what you suggested, but to no effect...

  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    Jul 14, 2017 @ 09:03
    Alex Skrypnyk
    0

    Did you change clientDependency version in the config?

  • Mathias Andreasen 43 posts 155 karma points
    Jul 14, 2017 @ 09:06
    Mathias Andreasen
    0

    I don't know what you mean, are you referring to this?

    ClientDepedency.config

    <clientDependency version="1901956542" fileDependencyExtensions=".js,.css" loggerType="Umbraco.Web.UI.CdfLogger, umbraco">
    

    Do I change that version to an arbitrary one?

  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    Jul 14, 2017 @ 09:07
    Alex Skrypnyk
    0

    Yes, change the version to another number.

  • Mathias Andreasen 43 posts 155 karma points
    Jul 14, 2017 @ 09:08
    Mathias Andreasen
    0

    Didn't work either..

  • Jonathan Richards 288 posts 1742 karma points MVP
    Jul 14, 2017 @ 09:09
    Jonathan Richards
    1

    Hey,

    Just checking but

    1. Can you check in your browser that your js files are being loaded. eg. Press F12 in Chome, Network tab and press refresh.

    2. Is your package manifest file in the correct place. "/App_Plugins/Scandbio/package.manifest"

    Cheers

  • Mathias Andreasen 43 posts 155 karma points
    Jul 14, 2017 @ 09:12
    Mathias Andreasen
    0

    Yes to both of your questions

  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    Jul 14, 2017 @ 09:10
    Alex Skrypnyk
    0

    So it's not the cache issue, is it right file paths?

    Can you try to access js files from browser by direct link ""~/App_Plugins/Scandbio/backoffice/ecommerce/edit.controller.js""?

    Sorry, I know it's maybe strange advice.

  • Mathias Andreasen 43 posts 155 karma points
    Jul 14, 2017 @ 09:13
    Mathias Andreasen
    0

    Yes I can

  • Jonathan Richards 288 posts 1742 karma points MVP
    Jul 14, 2017 @ 09:21
    Jonathan Richards
    1

    I have to agree with Alex Skrypnyk, this does feel like either a caching issue or there is a bug in your js file. I'd be tempted to remove all the code within the javascript controller and test again. eg. Just have

     angular.module("umbraco").controller("Scandbio.EditController", function ($scope, notificationsService, dialogService, assetsService, ecommerceResource) {
        alert('hi');
    )}
    
  • Mathias Andreasen 43 posts 155 karma points
    Jul 14, 2017 @ 09:23
    Mathias Andreasen
    1

    I've done just that, here's my updated edit.controller.js

    angular
    .module("umbraco")
    .controller("Scanbio.EditController", function ($scope) {
        console.log('^_____^');
    });
    
  • Jan van Helvoort 17 posts 190 karma points c-trib
    Jul 14, 2017 @ 09:37
    Jan van Helvoort
    0

    in your code, there is a typo

    Scanbio.EditController -> Scan**d**bio.EditController
    
  • Mathias Andreasen 43 posts 155 karma points
    Jul 14, 2017 @ 09:42
    Mathias Andreasen
    0

    Same error with typo fixed

  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    Jul 14, 2017 @ 09:30
    Alex Skrypnyk
    0

    Are you using https or http? The same protocol for js and html requests?

  • Mathias Andreasen 43 posts 155 karma points
    Jul 14, 2017 @ 09:32
    Mathias Andreasen
    0

    HTTP

  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    Jul 14, 2017 @ 10:08
    Alex Skrypnyk
    1

    I gave up :)

  • Mathias Andreasen 43 posts 155 karma points
    Jul 14, 2017 @ 10:43
    Mathias Andreasen
    0

    I don't blame you :D

    I'm starting to think that it's easier just to create a normal, plain MVC Project that implements what I wanted to do in a custom section/plugin.

    Thanks for your help though!

  • Mathias Andreasen 43 posts 155 karma points
    Jul 14, 2017 @ 12:33
    Mathias Andreasen
    0

    Okay... now it works.

    I havn't done anything, but now everything works. This is the second time this has happend to me, that the system seems to "repair" itself:

    https://our.umbraco.org/forum/using-umbraco-and-getting-started/76521-failed-to-retrieve-data-for-application-tree-merchello

    This is one of the most frustrating things about Using Umbraco, it feels like it caches everything it can get it's fithly hands on...

    I have NO IDEA what fixed my issue, which is a bigger issue in and of itself. Once again Umbraco has left a bitter taste in my mouth... yay

  • Anders Bjerner 487 posts 2990 karma points MVP 8x admin c-trib
    Jul 15, 2017 @ 12:11
    Anders Bjerner
    1

    By default, Umbraco will cache the JavaScript and CSS files that you specify in the backoffice. As you write, Umbraco will cache these files pretty hard. There are however a few ways to clear the cache.

    1. As written earlier in this thread, bumping the version name in ~/Config/ClientDepedency.config will force Umbraco to clear it's cache

    2. Recycling the application pool will also clear the cache - eg. if you build a new DLL of your project

    3. In ~/Web.config, you should have a line similar to <compilation defaultLanguage="c#" debug="false" batch="false" targetFramework="4.5" numRecompilesBeforeAppRestart="50"> (here copied from an Umbraco 7.6.4 installation). If you change debug="false" to debug="true", Umbraco will run in debug mode, which regarding packages, will mean that JavaScript and CSS files are no longer bundled and minified by ClientDependency.

      This makes it much easier to develop and test your packages (or code in general) locally. However you should then also make sure that your live environment doesn't run in debug mode.

      The JavaScript and CSS files (and also your HTML views) may still be cached your browser. If you're using Chrome, you can use it's Developer Tools to get around the caching.

    I hope that helps a bit ;)

  • Marcio Goularte 388 posts 1360 karma points
    May 21, 2020 @ 18:02
    Marcio Goularte
    0

    register if someone gets here too. My case was similar to yours. Unexplainable but after I changed the quotes, it worked

    Before:

    angular.module("umbraco").controller("MyController", function ($scope) {});
    

    After

    angular.module('umbraco').controller('MyController', function ($scope) {});
    
Please Sign in or register to post replies

Write your reply to:

Draft