Getting Javascript to Load in Mobile Client

Use this board to ask questions or have discussions with other Rich Displays users.
mwalter
Experienced User
Posts: 140
Joined: Wed Sep 14, 2016 2:58 pm
First Name: Mark
Last Name: Walter
Company Name: Paragon Consulting Services
Contact:

Getting Javascript to Load in Mobile Client

Post by mwalter »

I'm having an issue getting a javascript file to load into the mobile client. Works fine in the browser.
I was having issues with external CSS as well, till I used the following method:

Code: Select all

pui.loadCSS(pui.normalizeURL("/profoundui/userdata/custom/css/NexusDevice.css"));
In the format's onLoad event.

So, I tried the following method in the same event:

Code: Select all

pui.loadJS(pui.normalizeURL("/profoundui/userdata/custom/js/PickToBox.js"));
The CSS loads, however the javascript does not. Or at least, I don't think it does. WHen I try run one of the functions, the mobile client returns -0 in an alert window.
User avatar
Megan
Profound Logic Staff Member
Posts: 90
Joined: Mon Sep 11, 2017 12:15 pm
First Name: Megan
Last Name: Bond
Company Name: Profound Logic
Phone: 5623227473
State / Province: California
Zip / Postal Code: 92692
Country: United States
Contact:

Re: Getting Javascript to Load in Mobile Client

Post by Megan »

Hello Mark,

Yes, this is currently how the Mobile Client works. You'll need to import your custom CSS and JavaScript either as you have shown above or by using the screen properties of the Rich Display File or linking them in the start.html. It is done this way with the Mobile Client because timeouts and other functions may need to work differently with different values or even not be used at all, so we do not automatically pull it in as we do with browsers.

Hope this clears up any confusion!

Thanks,
~MEGAN BOND
Technical Support Specialist
support@profoundlogic.com
mwalter
Experienced User
Posts: 140
Joined: Wed Sep 14, 2016 2:58 pm
First Name: Mark
Last Name: Walter
Company Name: Paragon Consulting Services
Contact:

Re: Getting Javascript to Load in Mobile Client

Post by mwalter »

Not really. Even with the method above, it's not working. The javascript is not loading.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Getting Javascript to Load in Mobile Client

Post by Scott Klement »

Mark,

Have you looked in the server's error_log to determine what happens when this HTTP request is made? Have you tried using debugging tools to see what's going on?

IMHO, it's a bad idea to put your JS/CSS files under userdata/custom in this case. When running from a traditional (i.e. something besides the mobile client or PhoneGap) Profound UI interface, files in that directory are loaded automatically. Since you are manually loading them with the JavaScript APIs, this is not needed, and can be causing confusion. For example, you test your app on the PC and it works, but it doesn't work in the mobile client.. well, that could mean your JavaScript calls to loadCSS or loadJS aren't working... but you wouldn't know that because userdata/custom would load automatically on the PC... so it makes it more difficult to debug, because you can't do your debugging on the PC.

That's not the cause of the error, of course... but it may be adding to the confusion.
mwalter
Experienced User
Posts: 140
Joined: Wed Sep 14, 2016 2:58 pm
First Name: Mark
Last Name: Walter
Company Name: Paragon Consulting Services
Contact:

Re: Getting Javascript to Load in Mobile Client

Post by mwalter »

As per Scott, I changed the location of the CSS and JS. Now, the Javascript is loading, however, I'm getting an error on something. I'm not sure what, because I'm not sure how to debug the running javascript in the mobile client. The server error logs don't show anything. Any ideas how to see where this is happening besides putting an Alert in the JS after every statement in the script?

UPDATE: The plot thickens. The code works fine in the Chrome Browser on my Galaxy S7. But, not in the mobile client? Any ideas? Any way to debug?

Also, just realized that the grid will not scroll in the mobile client.
User avatar
Megan
Profound Logic Staff Member
Posts: 90
Joined: Mon Sep 11, 2017 12:15 pm
First Name: Megan
Last Name: Bond
Company Name: Profound Logic
Phone: 5623227473
State / Province: California
Zip / Postal Code: 92692
Country: United States
Contact:

Re: Getting Javascript to Load in Mobile Client

Post by Megan »

Hello Mark,

We're sorry to hear that you are still having issues with this! Could you please contact us by email at support@profoundlogic.com so that we may add you to an existing support ticket for the scrolling issue and assist you further with your debugging issues?

Thanks!
~MEGAN BOND
Technical Support Specialist
support@profoundlogic.com
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Getting Javascript to Load in Mobile Client

Post by Scott Klement »

I'm not sure why this would work in Chrome but not the mobile client. As Megan said, if you report this to support, they can probably help debug it.

The obvious culprit would be something with the pui.normalizeURL not working, since that's what would be different between the mobile client vs chrome. But, I can clearly see that you are calling it... so it should work. Debugging it would be the best solution, here.

Also, maybe this should be easier. We didn't want to automatically load everything under userdata/custom in mobile (like we do for browser) because mobile devices often run on a slow connection, or have worse reception due to distance from cell phone towers, etc, etc. So we are trying to load as little as possible... but sometimes you do want to load something in a mobile app without having to hard-code it in the screen itself. Seems like it' should be easier to do that. If you agree, would you please contact support@profoundlogic.com and put in a feature request?

Thanks!
mwalter
Experienced User
Posts: 140
Joined: Wed Sep 14, 2016 2:58 pm
First Name: Mark
Last Name: Walter
Company Name: Paragon Consulting Services
Contact:

Re: Getting Javascript to Load in Mobile Client

Post by mwalter »

Thanks Scott.

Still waiting on support to help debug this.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Getting Javascript to Load in Mobile Client

Post by Scott Klement »

Support replied to you on Tuesday morning asking for additional information, and is waiting for your response.
mwalter
Experienced User
Posts: 140
Joined: Wed Sep 14, 2016 2:58 pm
First Name: Mark
Last Name: Walter
Company Name: Paragon Consulting Services
Contact:

Re: Getting Javascript to Load in Mobile Client

Post by mwalter »

Sorry, Scott. I missed the email. I'll respond now.
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests