Extending the HTML trick: using actual images

  • Post comments:3 Comments
  • Reading time:4 mins read

Eric Sevareid famously said that the chief cause of problems is solutions. The same applies to the HTML trick I blogged about yesterday. As soon as you solve the problem of using HTML directly in your control add-ins, another problem arises: what do you do with actual images your control add-in includes?

This post explains how to solve that problem, and how to make it possible for your control add-in to both use HTML for defining UI and use relative control add-in paths to images.

Let’s dig in.

(more…)

Continue ReadingExtending the HTML trick: using actual images

NAV TechDays 2018 Demos: Customer Star Rating

  • Post comments:12 Comments
  • Reading time:3 mins read

I usually post my NAV TechDays demo stuff for you to use and abuse, and this year won’t be an exception. There are three changes, to previous years, specially the last year. First, you won’t need to wait until New Year’s Eve for me to post my stuff. Second, I’ll blog each of the demos individually, because of the third reason. Third, I don’t want to merely dump my code here with a big fat disclaimer; no – I’ll dump it with a big fat disclaimer and some explanations about what the code does and why.

So, here we go, the first demo (actually the second, because I already posted that Muppet Theme): Customer Star Rating control add-in.

(more…)

Continue ReadingNAV TechDays 2018 Demos: Customer Star Rating

Encapsulation in JavaScript

  • Post comments:4 Comments
  • Reading time:6 mins read

This will be my last post in the “JavaScript for (C/)AL Developers” series today. If I continued blogging about nearly pure JavaScript stuff, you could reasonably ask if this is in fact an NAV blog or a JavaScript one. It’s still NAV, and while the stuff I am about to write about is purely a JavaScript concept, I find it highly relevant for any control add-in developer. So, hold my beer, and bear with me for another one.

One of the complaints I often hear about JavaScript is that in JavaScript there is no encapsulation. This is almost completely true, except for the fact that it’s entirely false.

Where is the problem in the first place, and then what is the solution? Let’s dive in.

(more…)

Continue ReadingEncapsulation in JavaScript

Preventing trampling over $

  • Post comments:8 Comments
  • Reading time:9 mins read

In my previous post, I’ve written about the situation when you (or somebody you trust) redeclares the $ variable, thus inadvertently breaking all your jQuery code. I’ve also explained how to remedy for it inside the code you write by applying the Immediately Invoked Function Expression (IIFE) or Self-Executing Anonymous Function pattern.

However, is there anything you can do to prevent anyone from trampling over $ or jQuery variables in the first place?

As I said in my last post, yes, and no.

Let’s take a closer look at it.

(more…)

Continue ReadingPreventing trampling over $

Why doesn’t my jQuery work?

  • Post comments:9 Comments
  • Reading time:8 mins read

First, a disclaimer. This post is written for (C/)AL developers who are struggling with JavaScript, who copy and paste JavaScript code from Stack Overflow right into VS Code and are happy when it works, and confused when it doesn’t. Still, if you are not a (C/)AL developer but want to learn a bit of JavaScript yourself, this post is not at al about AL, it’s purely about JavaScript, and about demystifying a piece of it that JavaScript developers take for granted, and that developers with experience only with simpler languages (such as AL) find confusing.

Now let’s jump into the point. A friend asked me for help with a control add-in in which “jQuery doesn’t work, I can do jQuery() but I cannot do $()”

This is one of the schoolbook examples of what happens when you don’t isolate scope in JavaScript, so let’s first see what happened, and then let’s see how you can fix it.

(more…)

Continue ReadingWhy doesn’t my jQuery work?