JQuery/Wicket Error

Forum to discuss the Web client version of Servoy.

JQuery/Wicket Error

Postby bcusick » Thu Apr 20, 2017 11:32 pm

Hey Guys,

I'm doing something really simple in a HTML area - just want to fill the contents of a
Code: Select all
<div>
in an HTML area:

Code: Select all
sDivData = "<span class='inputControl'>" + "this is the span" + "</span>";
sScript = 'var thisDiv=document.getElementById("irbResults"); thisDiv.innerHTML="' + sDivData + '";setDatePickers();';
plugins.WebClientUtils.executeClientSideJS(sScript);


When it executes the script I get this error:

2017-04-20_14-23-37.png


Does anyone have a clue as to what is going wrong? It looks like it's having some problem with the BUSY plugin?

Any help would be greatly appreciated!

Thanks!

Bob
You do not have the required permissions to view the files attached to this post.
Bob Cusick
bcusick
 
Posts: 1183
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Re: JQuery/Wicket Error

Postby david » Sun Apr 23, 2017 4:57 pm

What is the code for "setDatePickers()"?

"$.blockUI" object was not initialized (or overwritten) further up your code example. So some kind of event in your code got in the way of Wicket's event flow. Don't see anything wrong with your code so "setDatePickers()" is the next stop.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1723
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: JQuery/Wicket Error

Postby bcusick » Mon Apr 24, 2017 4:23 pm

Yeah, thanks David!

It's really strange - but I can't isolate the problem. I call the same code from another place, and it works just fine.

I'll have to keep messing with it - but's pretty frustrating... :shock:

The "setDatePickers()" just initializes two fields to contain a date picker control.

Even if I take that out - just calling the plugins.webClientUtils.execute() - to do ANYTHING (e.g. alert("hi") or even just console.log("hi')) even throws the error (in the browser console - no error in Servoy).
Bob Cusick
bcusick
 
Posts: 1183
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Re: JQuery/Wicket Error

Postby david » Mon Apr 24, 2017 5:30 pm

bcusick wrote:...I call the same code from another place, and it works just fine...Even if I take that out - just calling the plugins.webClientUtils.execute() - to do ANYTHING (e.g. alert("hi") or even just console.log("hi')) even throws the error (in the browser console - no error in Servoy).


Now I'm suspicious of the "I call the same code from another place". You start messing with client-side javascript in Servoy's Wicket context and it is easy mess Wicket up. Overwriting events, adding duplicate class names, overwriting data, etc.

In this situation, $.blockUI is no longer defined (at the global scope no less). Either you wiped it earlier (less likely), or you did something that caused Wicket to wipe it (more likely).

To debug, see if $.blockUI exists in the client after each of your JS hacks using Chrome's console in the debugger. You can also put "debugger;" statement in strategic places in your client-side JS code to trigger the debugger in Chrome and then step through your JS. All the while keep your eye on $.blockUI.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1723
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: JQuery/Wicket Error

Postby bcusick » Mon Apr 24, 2017 6:31 pm

Thanks, David - super advice!

BTW: When I ditch the busy plugin - all works as expected. THAT's the confusing thing.

I appreciate your helpful advice!
Bob Cusick
bcusick
 
Posts: 1183
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Re: JQuery/Wicket Error

Postby david » Mon Apr 24, 2017 6:49 pm

The busy plugin is just doing the same thing you are: injecting client-side JS code into Wicket. In this case, just some generic JQuery busy plugin.

As such, it is subject to the same rules as your code is and can mess wicket up just as easily as you. Your code + busy plugin + Wicket === I'm not surprised something breaks.

Skip the busy plugin and include one of the many JQuery busy plugins yourself. Much easier to debug.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1723
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: JQuery/Wicket Error

Postby bcusick » Mon Apr 24, 2017 7:11 pm

UPDATE:

David - you were totally right! Wicket "dumped" the previous busy plugin JS when it tried to reload the window because of the DOM change.

The fix was super stupid-easy: just put in an explicit
Code: Select all
plugins.busy.prepare()
(which re-injects the script back into the header).

Just wanted to say THANKS AGAIN for getting me going in the right direction!
Bob Cusick
bcusick
 
Posts: 1183
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Re: JQuery/Wicket Error

Postby david » Mon Apr 24, 2017 7:20 pm

Cool!
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1723
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: JQuery/Wicket Error

Postby bcusick » Mon Apr 24, 2017 7:22 pm

UPDATE #2:

It looks like the FIRST TIME a window opens (I'm performing this in a new window) - the busy plugin stuff gets loaded into the header (I explicitly call it on the onShow event). Everything works just fine.

If I close that window, then click the link to open the same form in a new window (the old one was closed) - then eventhough the busy.prepare() RUNS - it doesn't put the javascript in the header.

If I back all the way out, and re-launch - the FIRST time through (launching the new window) - everything is fine. If I close the window and re-launch it - then even though the onShow fires - it fails to load the javascript in the header.

:evil:
Bob Cusick
bcusick
 
Posts: 1183
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Re: JQuery/Wicket Error

Postby bcusick » Mon Apr 24, 2017 7:35 pm

There were other windows in the solution that referenced the busy plugin (with busy.prepare() ).

Once I commented out ALL the references to the busy plugin - BAM! Worked like a champ (EVERY time).
Bob Cusick
bcusick
 
Posts: 1183
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA


Return to Servoy Web Client

Who is online

Users browsing this forum: No registered users and 1 guest