Get title of row action button in snippet

  • 1
  • Question
  • Updated 2 years ago
  • Answered
Hello all! This is driving me crazy... I'm trying to get the title of a row-action button when it's clicked. Should be straightforward! But I'm failing...

I've tried:

arguments[0].button.title
arguments[0].button.prop('title')
arguments[0].button.attr('title')
Could someone do me a favour and point me in the right direction?

Many many thanks!

Louis
Photo of Louis Skelton

Louis Skelton

  • 4,878 Points 4k badge 2x thumb

Posted 2 years ago

  • 1
Photo of David Giger

David Giger

  • 1,758 Points 1k badge 2x thumb
Hi Louis

This is very strange, I'm also not getting any results...
When logging any other properties than title it returns the correct value (e.g. baseURI), but title just returns an empty/blank value...
I also tried to convert it to a JQuery DOM-Element and other funny stuff, but accessing the values directly gave the best results

Script:
var params = arguments[0],	
    $ = skuid.$;
console.log(arguments[0]);
console.log('baseURI: ' + arguments[0].button[0].baseURI);
console.log('title: ' + arguments[0].button[0].title);
Console output:



Although the property title is available in the arguments object:



This is really funny...

Cheers
Photo of Louis Skelton

Louis Skelton

  • 4,878 Points 4k badge 2x thumb
Thanks David. Yes, I should say that I created the jQuery object before trying attr() and prop(). Is it something to do with the fact that the button properties are the result of a returned function? Something like that? I'm befuddled.
Photo of David Giger

David Giger

  • 1,758 Points 1k badge 2x thumb
I really have no idea why it displays a blank value, because the value is definitely in the arguments object and not even accessing it via the object properties returned a value... 
Photo of Amy Dewaal

Amy Dewaal, Official Rep

  • 8,200 Points 5k badge 2x thumb
David and Louis,

The title is blank because of the way tooltips work. When you mouse over the row action button the tooltip is overwriting the title property. So, when you ask for the button title in the snippet you are getting blank because tooltips has overwritten the title. To see this in action look at the row action button element in chrome console. You can watch the title property change as you mouse over the button.

Thanks!
Amy
Photo of Louis Skelton

Louis Skelton

  • 4,878 Points 4k badge 2x thumb
Thanks Amy, that's swell. I was hoping to grab the title of the button so I could avoid having multiple snippets for multiple buttons. Instead I was hoping to have one snippet and then the button title would dictate how that snippet was executed. With your response in mind, do you know of a neat way to get the button title that executed the snippet? As I've explained, I can easily just replicate my snippet for each button so no worries if not! Ta!
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Since you have the jquery wrapped dom element for the button, you could just run something like this?

arguments[0].button.find('.ui-button-text').text();
Photo of Amy Dewaal

Amy Dewaal, Official Rep

  • 8,200 Points 5k badge 2x thumb
Louis,

Unfortunately, it looks like Matt's way doesn't work, and I can't think of another way :( To get the title you'd have to click the button in the javascript, and that would leave out the mouseover, but it would also put you in an infinite loop. Looks like copying the snippet is your best option.

Thanks!
Amy