- This topic has 8 replies, 2 voices, and was last updated 13 years, 4 months ago by
alexbernal.
-
AuthorPosts
-
alexbernalMemberI got the 15 day trial version of MobiOne and I’ve had not luck getting JQuery code to be recognized.
I have a form with one edit field and one button. Pushing the button will cause and alert with the content of the edit field to pop up. The problem is that when I write the JavaScript code using jQuery it does not work, but when I use standard JavaScript it works fine.WORKS: alert(document.getElementById(‘m1-testapp2-textField1’).value);
DOES NOT WORK: alert($(‘#m1-testapp2-textField1’).val());
I’m using Windows 7 64bit.
February 25, 2012 at 2:02 pm #323711
support-michaelKeymaster>DOES NOT WORK: alert($(‘#m1-testapp2-textField1’).val());
That’s odd for jquery to be N/A to your app. From your description I understand it to be a simple 2 widget mobione UI design with a JS action that runs the JS jquery snippet you provided. I wrote a similar app and that had no issues. So this is a puzzle?
Let’s try accessing the inputfield without going through the action mechansim or using alert().
1) Run your app in the Test Center. Enter some content in your inputfield.
2) Open the DOM Inspector and expand the Console (at bottom of DOM inspector panel).
3) Enter your jquery snippet followed by enter and you should see the value displayed as shown below.
See attachment jquery-test3.pngHere are screenshots from my example and the src is attached at the end.
See attachment jquery-test1.png
See attachment jquery-test2.pngSrc design file
See attachment jquery-access-test.mobiAttachments:
You must be logged in to view attached files.February 26, 2012 at 12:03 am #323719
alexbernalMemberThanks Wayne for the prompt reply. It didn’t make any sense to me either. I thought a restart of the application after installation (which I had not done) would do the trick, but it didn’t. I decided to purchase a license anyway just to see if it was a limitation that had something to do with the trial version and guess what…it now works as it should. Perhaps something to look into on your end. Thanks again!
March 7, 2012 at 1:36 pm #324059
alexbernalMemberHello Wayne, I thought everything was working, but now that I have the app almost finish, it is behaving the same way it did before. It’s driving me crazy. When I add the SAME javascript code to my app, it does not work, but when I add it to a one page test app it works fine. What am I doing wrong?
Please help! This is very frustrating. I have attached both the test app and my app page that is not working.
Attachments:
You must be logged in to view attached files.March 7, 2012 at 1:48 pm #324061
alexbernalMemberHere is an image of the error message generated when I click the button.
Attachments:
You must be logged in to view attached files.March 7, 2012 at 3:45 pm #324068
support-michaelKeymasterThanks for the extra details. I agree something is goofed up.
Q1: can you verify that the jquery library is loading?
– Load your app in the Test Center and open the Resource Monitor tool as shown
See attachment jquery-load-confirm.pngQ2: if you do not see the jquery lib loading in #1 then open a File Explorer to the generated HTML code and look in the /res subdirectory for the jquery library. Is it present?
Q3: have you manually modified the generated code in anyway?
Attachments:
You must be logged in to view attached files.March 7, 2012 at 5:35 pm #324076
alexbernalMemberIt seems to be loading fine, and I have not modified any generated code.
Attachments:
You must be logged in to view attached files.March 8, 2012 at 6:40 am #324098
support-michaelKeymasterYour recent example gave our dev team the clue they needed to identify the problem. This is a bug which we are fixing today for the 1.5 release planned for early next week. The problem is that a Run JS action’s code is being obfuscated and goofing up a jquery reference. If you need a workaround before the 1.5 release you can move the action code to a new function you create in the main_custom.js file which the JS action will call.
March 8, 2012 at 11:21 am #324105
alexbernalMemberThanks Wayne, I tried the workaround and it worked, however, I think I will wait for the release next week to complete the project.
-
AuthorPosts