Options

JavaScript-Add-In causing a Problem when trying to Customize the Ribbon

byronicbyronic Member Posts: 22
edited 2016-05-10 in NAV Three Tier
Hello everyone,

I've got a little problem with a JavaScript-based Add-In that I made.

It is working as intended but now when I try to customize the ribbon of the page I get an error that says "The connection to the server has been lost. The application will close." This happens for example when I try to add some option from the left to the right and press "OK".

Whats especially strange about this is, that I made another JavaScript-based Add-In, that almost 100% works the same but it doesn't give me that error.

Both Add-Ins are made for NAV 2016.


Here are the 2 VisualStudio Projects:

http://www.filedropper.com/javascriptaddins

The one that is working is the "SliderAddin", the one that gets the error is the "InPageAmpel".

Thank you in advance

Best Answers

Answers

  • Options
    Jan_VeenendaalJan_Veenendaal Member Posts: 206
    I experienced similar issues. In my case it depended on the actual placement of the control add-in. First I had it inside a Fast-tab on a card page: the client crashed (same message as you get) on some actions. Then I moved the control-addin to a factbox part on the same page: everything worked fine.
    Jan Veenendaal
  • Options
    byronicbyronic Member Posts: 22
    That is a good tip, thank you.

    But I need mine to be in one of the Fast-Tabs.

    Also my other Add-In, which basically does the same (append pictures to the Add-In container), works without getting this error when customizing the ribbon. I just can't see the difference that would prevent that.
  • Options
    byronicbyronic Member Posts: 22
    Hi EvR, thanks for your tip.

    However my JavaScript/CSS Resources are quite minimal, there are very few lines in them.
  • Options
    byronicbyronic Member Posts: 22
    edited 2016-05-12
    Apperently EvR was right. I underestimated the size of the pictures in the resources. Thank you all for your help!
  • Options
    byronicbyronic Member Posts: 22
    Ok, now when I'm using the same Add-In (this time I tried with the SliderAddin, which just has pictures that together are in size of ~5 KB) 2 or more times on the same page I'm getting the same error. I'm guessing it's the same issue with the size of the resource being to much.

    I tried to put the Max Items in Object Graph property in server settings to 1024, which increases the loading time too much to be an option.

    Now using jQuery via ScriptUrls isn't an option, and loading the resources to the webserver isn't either.

    While there is the possibility to use the compressed, production version, it's still a little too much of size.

    Could someone maybe tell me if there is a way to compress it way further (maybe deleting not used/needed code)?
    The SliderAddin for example just has these lines of code in it:

    var navContainer;
    var navControl;

    $(document).ready(function () {
    InitializeControl();
    Microsoft.Dynamics.NAV.InvokeExtensibilityMethod("ControlAddInReady", null);
    });


    function InitializeControl() {
    navContainer = $('#controlAddIn');
    }


    function SetSliderValue(value) {

    if (value == true) {
    navContainer.append('<div class="img"><img draggable="false" onclick="javascript:OnSliderClick()" style="width:45px;height:25px;" class="test" position:fixed /></div><script type="text/javascript">$(".test").attr("src", Microsoft.Dynamics.NAV.GetImageResource("slideronn.png"))</script>');
    } else {
    navContainer.append('<div class="img"><img draggable="false" onclick="javascript:OnSliderClick()" style="width:45px;height:25px;" class="test" /></div><script type="text/javascript">$(".test").attr("src", Microsoft.Dynamics.NAV.GetImageResource("sliderofff.png"))</script>');
    }
    }


    function OnSliderClick() {
    Microsoft.Dynamics.NAV.InvokeExtensibilityMethod("OnSliderClick", null);
    }




    Which parts of jQuery do I really need for this to work?
  • Options
    byronicbyronic Member Posts: 22
    Upping this thread once more in hope for a solution
Sign In or Register to comment.