Using jQuery in Custom Widgets (Bonita 7)

1
0
-1

How can I use jquery in my custom widgets? I have code like the following in my controller function:

  1. function ($scope) {
  2. this.doSomething = function(){
  3. $("someSelector")....
  4. //Do stuff
  5. }
  6. }

But when it gets executed I'm getting this error:

  1. ReferenceError: $ is not defined

What do I need to do to utilize jquery in my custom widgets?

Thanks David

Comments

Submitted by vincent.elcrin on Wed, 07/29/2015 - 23:56

Hi, did you try to add JQuery library as an asset to the custom widget?

Submitted by dharris on Thu, 07/30/2015 - 16:28

Thanks Vincent that does work. I was getting a bit confused because I was under the impressing that jQuery was already available. I was looking at the sources that get pulled into the page and saw that jquery is being pulled in when viewing my form from the portal. (I saw it from a URL like /bonita/portal/scripts/jquery/jquery-1.6.4.js?v=7.0.1). So I wasn't sure why I couldn't use it in my forms. I dug in a little more and saw that my form is actually getting displayed in an iframe so it won't have visibility to the scripts pulled in in the parent frame.

Thanks again David

Submitted by vincent.elcrin on Thu, 07/30/2015 - 16:30

Yeah we do wrap custom pages into iframe to avoid conflicts. This is also why we show the preview in an iframe so the JQuery you see from the vendors...min.js is certainly from the UI Designer.

Vincent

No answers yet.
Notifications