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
Answers
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.
Basically, minify your javascript/css resources or edit a service config is it's still too large.
However my JavaScript/CSS Resources are quite minimal, there are very few lines in them.
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?