• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reference an element within the same table row

 
Ranch Hand
Posts: 2206
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my app I have a table row which in the last column has a Save icon fro saving the row data.

In the other cells when clicked a dialog box pops up where the user can enter details for that field. It is also a table of rows with a Save column.

I would like to click the Save icon in this dialog pop up and at the same time auto click the calling rows Save icon.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what you're asking, but (assuming you are using jQuery), you can click a button under script control with the .click() method.
 
Steve Dyke
Ranch Hand
Posts: 2206
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:I'm not sure what you're asking, but (assuming you are using jQuery), you can click a button under script control with the .click() method.



Thanks but how can I reference the button on the calling page. Remember the calling table has many rows each having a save button(set up with class and custom attribute). I need to reference the calling rows button within the called dialog.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jQuery has many methods to relate elements by relationships such as siblings and parents.

Within a table, one one of the most useful methods I've used is closest(), which finds the closest parent that matches the selector. So let's say we're in a handler for something that was clicked inside a table row (so the target is this). We can use:to locate the enclosing row (<tr>), and then find anything we want within that scope. Just replace some-selector with a selector that identifies the element to be selected.
 
Steve Dyke
Ranch Hand
Posts: 2206
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:jQuery has many methods to relate elements by relationships such as siblings and parents.



Thanks Bear.

I was thinking that you had shown me how to reference a control by using a selector comprised of the class name where the custom attribute equals a declared value.
 
Steve Dyke
Ranch Hand
Posts: 2206
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear I think I found my answer. But first when I run into a challenge I first try all I know which doesn't take long then I post my question. I don't just sit and wait on an answer but keep trying things. I don't mean to waste any of your time and most of the time I cannot figure it out anyway.

Here is what I came up with and it works:

 
Steve Dyke
Ranch Hand
Posts: 2206
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:jQuery has many methods to relate elements by relationships such as siblings and parents.

Within a table, one one of the most useful methods I've used is closest(), which finds the closest parent that matches the selector.



I want to get the contents of the value attribute. The following does not do the trick. Can you help with selector syntax?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steve Dyke wrote:Bear I think I found my answer.


What prevents your code from selecting multiple elements from multiple rows?

Steve Dyke wrote:I want to get the contents of the value attribute.


Of what? And did you really mean to pass the value as a selector?
 
Are you here to take over the surface world? Because this tiny ad will stop you!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic