Changing the HTML template of a widget breaks it!

0
Hi all Am a bit stuck with what I thought would be a simple challenge. At my company, all our pages that feature a Checkbox use a custom widget, rather than the default input. We do this because it is more agreeable with the stylesheet we use. However, every time we include one we must add a custom class, "checkbox". With this in mind, I would like to modify the widget so that it applies this class by default, to save devs time while building. I've been trying to include this line of code in the widget's HTML template class="checkbox"   Before: After: So, this works fine when the checkbox is included in the app. However, when the checkbox isn't in any pages and I try to run the app I am met with a blank screen and this error from the console   If it's relevant - my process for changing it is opening the MPK file in the AppName/widgets folder, changing the code and putting the MPK back in the folder. I was hoping someone could help answer my questions What can I add to this widget to add this class without causing issues? Do I need to change something in the javascript? Why does a widget cause issues like this when it is not included in any page?   Thanks  Luke
asked
4 answers
0

Don't mix up Dojo before 1.7 (dojo.addClass) and Dojo 1.7+ (domClass.add, domStyle.set). This may cause side effects in the AMD loader.

answered
0

Can use the developer tool in your browser to see if that throws an error as well? 

Perhaps you can use the following?

object.className += " checkbox";

or

object.classList.add('checkbox');
answered
0

This worked for me in a custom widget:

var checkBox = dom.create("input",{
  name: "checkBox" + layer.layer.id,
  value: layer.layer.id,
  checked: layer.layer.visible,
  type: "checkbox"						  
});

layer was a specific JavaScript object in my case, but idea should be clear from this.

answered
0

We have similar issues when we no longer use a widget in the project (the 404-error).

After you use the "Clean Deployment Directory" option in the Project menu, your project will start again.

answered