StealthRT
StealthRT

Reputation: 10552

IBM forms designer and making jQuery work with Dojo

I have the following code:

var dojoConfig = {
   baseUrl: "./",
   async: true,
   isDebug: true,
   parseOnLoad: false,
   packages: [
     {name: "jQuery", location: "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js", main: "jQuery"},
   ]
};

The code loads without issues but once i do this on a click button:

$(this).value();

It gives the error:

There was an error executing the onClick event code on item , page Welcome, form Form 1. Caused by: Error: Illegal reference to $

What all do I need to do in order to get both working on the forms? Is there a certain way i need to call the jquery?

Upvotes: 0

Views: 291

Answers (1)

Dimitri Mestdagh
Dimitri Mestdagh

Reputation: 44757

Replace your Dojo config with this:

var dojoConfig = {
  async: true,
  isDebug: true,
  parseOnLoad: false,
  packages: [{
    name: "jQuery",
    location: "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0",
    main: "jquery.min"
  }]
};

What happens if we do that is defining a module called jQuery (due to the name property) located at http://ajax.googleapis.com/ajax/libs/jquery/1.11.0.

if we then use:

require([ "jQuery" ], function() {

});

It will load the main file of the jQuery module, which is in this case jquery.min. It will look for it at the given location, so you will get:

http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js

That should work properly, though I don't think the .value() function is a proper function. Well, you can see it work at this Plunker: http://plnkr.co/edit/IE9y3cId6IHQfMKnyOtj?p=preview

Upvotes: 1

Related Questions