Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get selector attribute in jquery qTips?

I'm trying to get the "id" attribute of a tag that also calls jQuery qTips. The setup is as follows:

$('.selector').qtip({
   content: {
      text: 'Loading...', // The text to use whilst the AJAX request is loading
      ajax: {
         url: 'getInfo.php', // URL to the local file
         type: 'GET', // POST or GET
         async: false,
         data: { id: $(this).attr('id')}, // !! PROBLEM HERE
         success: function(data, status) {

            // Set the content manually (required!)
            this.set('content.text', data);
         }
      }
   }

});

The caller is as such:

<a href='http://www.google.com' class='selector' id='Jerome'>Jerome</a>

but for some reason $(this).attr("id") is undefined. The qTip shows up but is blank, and the GET call shows up as not passing any data in Firebug. What am I missing?

Thanks!

Edit: also, this.attr returns "this.attr is not a function"

like image 996
Rio Avatar asked Dec 05 '25 20:12

Rio


1 Answers

Try this it will solve your problem.

$('.selector').each(function(index, item){
  $(item).qtip({
   content: {
      text: 'Loading...', // The text to use whilst the AJAX request is loading
      ajax: {
         url: 'getInfo.php', // URL to the local file
         type: 'GET', // POST or GET
         async: false,
         data: { id: $(item).attr('id')}, // !! PROBLEM HERE
         success: function(data, status) {

            // Set the content manually (required!)
            this.set('content.text', data);
         }
      }
   }

});

});

like image 142
ShankarSangoli Avatar answered Dec 08 '25 09:12

ShankarSangoli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!