Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Reference an element within the same table row

 
Ranch Hand
Posts: 2038
1
  • Mark post as helpful
  • send pies
  • 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.
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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: 2038
1
  • Mark post as helpful
  • send pies
  • 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
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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: 2038
1
  • Mark post as helpful
  • send pies
  • 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: 2038
1
  • Mark post as helpful
  • send pies
  • 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: 2038
1
  • Mark post as helpful
  • send pies
  • 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
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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?
 
What do you have in that there bucket? It wouldn't be a tiny ad by any chance ...
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic