Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do i pick up this h:outputText value with jquery?  RSS feed

 
Victor Ade
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have this code multiple times on same page:



i'm trying to get the value of houtputext with id="iname" [directly below any clicked highlighter div] with the below code but its failing. why?


 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, many CSS purists will look down on you for using the <li> tag. And that's even before you start talking JSF.

Besides, a <li> tag should not be a direct child of a "div" tag. It should be a child of either "ol" (ordered list) or "ul" (unordered list). Without that parent element, the "li" doesn't know whether to render its body as a numbered item or as a bulleted item.

But CSS can do everything that the HTML list tags did and can do them more flexibly. Which is why CSS snobs look down upon list tags, relegating them to the same dustpile as the lost, but not lamented <font> tags.

So much for straight HTML. Now to further demolish your hopes and dreams.

The ui:repeat tag isn't as useful as it seems. People use it like it's a looping construct, when actually, like the h:dataTable, it's a UI element replication construct. In most cases, it's simpler to use a dataTable. The primary case where a dataTable fails and ui:repeat is an alternative would be if you had elements arranged beside each other horizontally rather than descending down the web page.

So rather than use div's, li's and ui:repeat, your page layout code will be a lot simpler using a dataTable and setting its CSS to render like whatever kind of list you want to display. This also makes the iterated elements more accessible.

The use of jQuery is also overkill here. Something more like this will work. Note that your end tags didn't seem to match up properly in your example and I've re-arranged things to make more sense:


"this" is a Java reserved word and may conflict with the VDL compiler, so I also renamed your ID.

I'm assuming that you have both plain and hover styles defined in your CSS for the style named "linklist". Note also that some style properties cascade from the containing outputLink tag.

The above link would then define the column element for a single-column dataTable.

Uh, and to make the link pop an alert instead of a jump, simply put the alert call in an onclick attribute of the outputLink. The onclick should return false to suppress the hyperlink jump.
 
Victor Ade
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim, but I'm not so keen on perfection just yet.
I'm starting to feel frustrated and I've been stuck on this for a while.
What I'm trying to achieve is simple yet I've been on it for soo long its starting to turn something else.
With each link i have on a particular webpage I want "identify" which one was clicked plus get the associated "iname" and send the "iname" to back end. Simple. That explains why I decide to put them in a parent div et al. So i can get the direct "iname" of the clicked link as the child of the div.
And I'm still stuck.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you are trying to achieve is simple, but the way that you are trying to achieve it is complicated. Complicated usually means that it will take a long time to design and debug and it may fail in strange ways.

It's a lot simpler to just skip the jQuery altogether and assemble the data on the server side the way I described it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!