Loading jquery + jquery-ui

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
23425675747
Posts: 4
Joined: Fri Oct 27, 2017 2:28 pm

Loading jquery + jquery-ui

Post by 23425675747 » Fri Oct 27, 2017 2:38 pm

Hi there,

i am a long time imacros user and i use jquery as follows:

Code: Select all

function myRequire( url ) {
   const XMLHttpRequest = Components.Constructor("@mozilla.org/xmlextras/xmlhttprequest;1");
   var ajax = XMLHttpRequest();
    ajax.open( 'GET', url, false );
    ajax.onreadystatechange = function () {
       var script = ajax.response || ajax.responseText;
       if (ajax.readyState === 4) {
          switch( ajax.status) {
             case 200:
             	eval.apply( window, [script] );
             	iimDisplay("script loaded: ", url);
             break;
             default:
             	iimDisplay("ERROR: script not loaded: ", url);
          }
       }
    };
    ajax.send(null);
}
myRequire("file:///jquery-3.1.0.min.js");
$ = window.$;
JQuery = window.JQuery;
myRequire("file:///jquery-ui.min.js");
Loading jquery and using it in my imacro script works as expected but the jquery-ui plugin does not seem to get properly registered, cause a call to:

Code: Select all

$("#jqDialog").dialog();
result in the following error:

Code: Select all

TypeError: $(...).dialog is not a function, line 971 (Error code: -991)
This is the normal error you get when jquery-ui did not load correctly (in a non imacros context).

I am not really sure what is going on but for some reason it doesn't work.
Hope someone else had this problem before and can give me a hint..

*edit:
System specs:
imacros: 8.9.7
firefox: 55 - 56
OS: Arch Linux (Kernel: 4.9.58)

Cheers
Last edited by 23425675747 on Mon Oct 30, 2017 2:13 pm, edited 1 time in total.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Loading jquery + jquery-ui

Post by chivracq » Sat Oct 28, 2017 2:56 am

23425675747 wrote:Hi there,

i am a long time imacros user and i use jquery as follows:

Code: Select all

function myRequire( url ) {
   const XMLHttpRequest = Components.Constructor("@mozilla.org/xmlextras/xmlhttprequest;1");
   var ajax = XMLHttpRequest();
    ajax.open( 'GET', url, false );
    ajax.onreadystatechange = function () {
       var script = ajax.response || ajax.responseText;
       if (ajax.readyState === 4) {
          switch( ajax.status) {
             case 200:
             	eval.apply( window, [script] );
             	iimDisplay("script loaded: ", url);
             break;
             default:
             	iimDisplay("ERROR: script not loaded: ", url);
          }
       }
    };
    ajax.send(null);
}
myRequire("file:///jquery-3.1.0.min.js");
$ = window.$;
JQuery = window.JQuery;
myRequire("file:///jquery-ui.min.js");
Loading jquery and using it in my imacro script works as expected but the jquery-ui plugin does not seem to get properly registered, cause a call to:

Code: Select all

$("#jqDialog").dialog();
result in the following error:

Code: Select all

TypeError: $(...).dialog is not a function, line 971 (Error code: -991)
This is the normal error you get when jquery-ui did not load correctly (in a non imacros context).

I am not really sure what is going on but for some reason it doesn't work.
Hope someone else had this problem before and can give me a hint..

Cheers
Hum, FCIM...! :mrgreen: (Read my Sig..., but mention your FCI when you open a Thread on this Forum if you want me to try to help you... :idea: )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
23425675747
Posts: 4
Joined: Fri Oct 27, 2017 2:28 pm

Re: Loading jquery + jquery-ui

Post by 23425675747 » Mon Oct 30, 2017 2:15 pm

chivracq wrote:Hum, FCIM...! :mrgreen: (Read my Sig..., but mention your FCI when you open a Thread on this Forum if you want me to try to help you... :idea: )
Fair enough. I am pretty sure this is not related to a specific imacros, firefox or OS version,so i figured it wasn't that important.
Anyway, i added it to my initial post.

Cheers
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Loading jquery + jquery-ui

Post by chivracq » Mon Oct 30, 2017 3:35 pm

23425675747 wrote:
chivracq wrote:Hum, FCIM...! :mrgreen: (Read my Sig..., but mention your FCI when you open a Thread on this Forum if you want me to try to help you... :idea: )
System specs:

Code: Select all

imacros: 8.9.7
firefox: 55 - 56
OS: Arch Linux (Kernel: 4.9.58)
Fair enough. I am pretty sure this is not related to a specific imacros, firefox or OS version,so i figured it wasn't that important.
Anyway, i added it to my initial post.

Cheers
"... I am pretty sure this is not related to a specific imacros, firefox or OS version..."
=> You could be right, but I usually simply don't read the Qt and certainly don't answer if that Info is not mentioned... :wink:
You could have mentioned the 'jQuery' Version(s) as well, even if it/they can be found in your Script...:

Code: Select all

jQuery v3.1.0_min + jQuery UI v1.12.1_min(?).
But OK, you are on v8.9.7 for FF, good-good as a lot of Functionality/Commands are not supported anymore or got broken in v9.0.3 for FF...

But hum..., I don't use '.js' Scripts, and 'jQuery' even less, ah-ah...!, so I'm afraid I won't be of much Help on this one..., but I don't know if you searched the Forum, but we have quite a few other Threads related to 'jQuery' (and a few fairly recent as well, from only a few months ago) and the (Advanced) Users who posted their Script might be using using a different way to call 'jQuery' in their Script... :idea:

The only "Suggestion" I would have is that I see that you call 'jQuery' from a Local Copy located in your Root Directory..., you could try placing those Files in some Intermediary Folder, as..., not sure about Linux..., but on Windows OS'es, File-IO Access is prevented (from the Browser since FF14 I think) for Files located in the 'C:\' Root Directory... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Loading jquery + jquery-ui

Post by chivracq » Mon Oct 30, 2017 5:11 pm

But OK, a few more "Thoughts", ah-ah...!

I guess my "Sugg" about an "Intermediary Folder" for the 'jQuery' Libraries won't really make a Difference, you would get a different RuntimeError I would think, and you wouldn't be able to access any 'jQuery' Functionality at all otherwise... :oops:

But I suspect you might be hitting a Bug in iMacros for FF since v7.5 related to 'alert()'/'confirm()'/'prompt()' as I reckon this 'dialog()' 'jQuery' Function probably relies on one of the 3 JS DialogBox Functions...

Those 3 Commands should still work if you call them "natively" from your '.js' Script without trying to use the 'jQuery' extra-Layer...

Or in the same Thread I already referred to, you have a Workaround where you can embed them within 'setTimeout()' provided by Advanced User @iimfun (who also uses 'jQuery' I think, so if you are a bit "lucky", he might notice and jump into your Thread...), that you might be able to apply to your Case...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
iimfun
Posts: 239
Joined: Tue Jul 19, 2016 1:06 pm

Re: Loading jquery + jquery-ui

Post by iimfun » Wed Nov 01, 2017 7:47 am

As to this particular problem I would load the jquery-ui script directly to the page.

Code: Select all

iimPlayCode('URL GOTO=javascript:document.body.appendChild(document.createElement("script")).src="file:///path/jquery-3.1.0.min.js";void(0);' + '\n' + 'WAIT SECONDS=1' + '\n' + 'URL GOTO=javascript:document.body.appendChild(document.createElement("script")).src="file:///path/jquery-ui.js";void(0);' + '\n' + 'WAIT SECONDS=1');

// calling a dialog
window.location.href = 'javascript:$("#jqDialog").dialog();void(0);';
Btw the idea has already appeared somewhere in my posts on this forum.
23425675747
Posts: 4
Joined: Fri Oct 27, 2017 2:28 pm

Re: Loading jquery + jquery-ui

Post by 23425675747 » Wed Nov 01, 2017 1:08 pm

Thx for the responses guys, I really appreciate it.

@iimfun i am sure this works to execute the script but i need it in the same context as the imacros javascript to be able to pass values back and forth.

To me it looks like jQuery-ui does not recognize the jQuery instance for some reason. This is probably a problem with the namespace of the two but i am not sure how to fix it.

I searched the forum but so far i only found solution on "how to load and use jQuery" but that's not my problem. jQuery works fine it's just that jQuery plugins don't.

Cheers
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Loading jquery + jquery-ui

Post by chivracq » Wed Nov 01, 2017 11:16 pm

iimfun wrote:As to this particular problem I would load the jquery-ui script directly to the page.

Code: Select all

iimPlayCode('URL GOTO=javascript:document.body.appendChild(document.createElement("script")).src="file:///path/jquery-3.1.0.min.js";void(0);' + '\n' + 'WAIT SECONDS=1' + '\n' + 'URL GOTO=javascript:document.body.appendChild(document.createElement("script")).src="file:///path/jquery-ui.js";void(0);' + '\n' + 'WAIT SECONDS=1');

// calling a dialog
window.location.href = 'javascript:$("#jqDialog").dialog();void(0);';
Btw the idea has already appeared somewhere in my posts on this forum.
Yep..., exactly why I mentioned to search the Forum a bit, but @OP didn't react at all... 8)

And hum, @iimfun, like each time you post stg, you never mention in which FCI (if...?) you've tested if the '#jqDialog' Call works using your Script, v8.9.7 for FF I guess + FF55 I guess, oh no, you were using FF52 Portable I think..., a bit tired of having to ask each time... :roll:
23425675747 wrote:Thx for the responses guys, I really appreciate it.

@iimfun i am sure this works to execute the script but i need it in the same context as the imacros javascript to be able to pass values back and forth.

To me it looks like jQuery-ui does not recognize the jQuery instance for some reason. This is probably a problem with the namespace of the two but i am not sure how to fix it.

I searched the forum but so far i only found solution on "how to load and use jQuery" but that's not my problem. jQuery works fine it's just that jQuery plugins don't.

Cheers
OK, Thanks for the "Thx", I guess the "s" in "guys" is for me, but you didn't react to any of my Sugg's, except mentioning your FCI with some "mumbling"... But OK, you are in "good hands with @iimfun" now (I don't know anything about 'jQuery' anyway...!, happy he jumped in, ah-ah...!), I'll follow the Thread from some distance... :wink:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
23425675747
Posts: 4
Joined: Fri Oct 27, 2017 2:28 pm

Re: Loading jquery + jquery-ui

Post by 23425675747 » Sat Nov 04, 2017 4:28 pm

chivracq wrote:Yep..., exactly why I mentioned to search the Forum a bit, but @OP didn't react at all... 8)
well, i did not react to what you said because your suggestions have nothing to do with what my problem. It's a problem with jQuery Plugins in general and not specific to jQuery-uis dialog plugin. Beside that, you said yourself, you don't work with jQuery, so i waited for people more familiar with it (as you suggested).

And yes, the "s" in guys was for you. ;)

Cheers
iimfun
Posts: 239
Joined: Tue Jul 19, 2016 1:06 pm

Re: Loading jquery + jquery-ui

Post by iimfun » Mon Nov 06, 2017 8:09 am

23425675747 wrote:i waited for people more familiar with it
It still seems that my approach is more promising and jQuery version independent. There should be some mechanism or task specific workarounds to access window context of the page itself. Sometimes I work with my own old tricks regarding that and at the moment have no enough time & motivation for extra searches and experiments, thus hope that you'll get a solution anyways.
chivracq wrote:... you are in "good hands with @iimfun" now ...
Yeah, thanks for advertising my expertise. Believe that I am not the only one who reads this.

Cheers!
Post Reply