question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to retrieve title and other data attribute from protip instance?

See original GitHub issue

Hi, How to retrieve title and other data attributes from protip instance on protipshow event.

$('.protip').on('protipshow', function(ItemInstance){
    console.log(ItemInstance.currentTarget.ptTitle, 'title');  //showing undefined
 });

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
wintercountercommented, Jul 12, 2022

I think the docs need to be updated. The first parameter in the callback is the jQuery event object, the second is the item instance.

$('.protip').on('protipshow', function(ev, ItemInstance){
    console.log(ItemInstance.data.title);
 });

Closing the thread, let me know if you still have problems and I reopen it.

0reactions
royallife88commented, Jul 13, 2022

Thank you! it’s working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

jQuery match data-attribute value of object within array of ...
I am trying to find an object in an array of data objects by matching the value of one of the attributes in...
Read more >
Using data attributes - Learn web development | MDN
To get a data attribute through the dataset object, get the property by the part of the attribute name after data- (note that...
Read more >
How to get the data attributes of an element using JavaScript
First, select the element which is having data attributes. ... Example 1: This example uses dataset property to get the data attributes of ......
Read more >
A Complete Guide to Data Attributes | CSS-Tricks
Everything you ever wanted to know about data attributes in HTML, CSS, and JavaScript.
Read more >
How to use Custom HTML5 Attributes in Thymeleaf
A quick guide to learning how to create HTML5 custom attributes using the Thymeleaf template engine.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found