Found the answer through playing around with a sample html file - in case
future novice users find this useful.
To hit a select list on an html page called "id=account_select" from a
script in a component.load file, normal jQuery syntax works with the .val()
function.
e.g. From the component script: $("#account_select").val() gets the value
of the list, while $("#account_select").value
does not.
In my novice state of jQuery and web2py, I had gotten confused due to using
this.value successfully on another function and thought just selecting
another element with $(...).value would work just as well. It didn't.
In hopes of simplifying the problem, I confused it: I created a simple
html file, double clicked on it in Finder and would view it in Safari.
Using an editor, I'd change the script in the html file, save it, and
reload the file in Safair to trial-and-error jQuery syntax until I got
something working. I was using jQuery's alert() to pop-up debug/see
responses from the $() code. I found that even though the page source
changed and was save with the correct code shown in the "show source"
option of Safari, sometimes the alert() would fire and sometime it
wouldn't. I loaded my html in PyCharm and used View > Preview File In...
[Safari] - and the alert() function worked every time... So I probably
had the script working much sooner than realized, but didn't see any
alert() responses and assumed it was jQuery erroring out (when it
wasn't)...
I've got to be by-far the most novice web2py / jQuery user here -- and am
simply hoping to pay-it-forward for other novices climbing the learning
curve in the future...
On Sunday, February 16, 2014 11:24:20 PM UTC-6, A36_Marty wrote:
>
> I have an index.html page that loads two elements:
> 1) A select list, id='account_select'
> 2) A component (open_positions.load)
>
> In the component (open_positions.load), I have a <script> that needs to
> get the value the select list (id='account_select') in the parent document.
>
> The following code does not work:
> $('#account_select").value
>
> Nor does this work:
> $("#account_select", parent.document).value
>
> What is the proper jQuery syntax to refer to the select list in the parent
> html file from a script within the component.load file?
>
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.