Page 1 of 2

Getting Javascript to Load in Mobile Client

Posted: Thu Jun 07, 2018 2:13 pm
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.

Re: Getting Javascript to Load in Mobile Client

Posted: Thu Jun 07, 2018 2:37 pm
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,

Re: Getting Javascript to Load in Mobile Client

Posted: Thu Jun 07, 2018 2:49 pm
by mwalter
Not really. Even with the method above, it's not working. The javascript is not loading.

Re: Getting Javascript to Load in Mobile Client

Posted: Thu Jun 07, 2018 2:55 pm
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.

Re: Getting Javascript to Load in Mobile Client

Posted: Mon Jun 11, 2018 9:08 am
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.

Re: Getting Javascript to Load in Mobile Client

Posted: Mon Jun 11, 2018 12:52 pm
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!

Re: Getting Javascript to Load in Mobile Client

Posted: Wed Jun 13, 2018 4:51 pm
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!

Re: Getting Javascript to Load in Mobile Client

Posted: Thu Jun 14, 2018 9:27 am
by mwalter
Thanks Scott.

Still waiting on support to help debug this.

Re: Getting Javascript to Load in Mobile Client

Posted: Thu Jun 14, 2018 2:30 pm
by Scott Klement
Support replied to you on Tuesday morning asking for additional information, and is waiting for your response.

Re: Getting Javascript to Load in Mobile Client

Posted: Fri Jun 15, 2018 10:29 am
by mwalter
Sorry, Scott. I missed the email. I'll respond now.