Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

this within Tipped not working

I need to retrieve a dynamic value - my example is somehow not working

This $(this).attr('data-id') should get this object '.phpc-event-list a'


var sdomain = 'http://'+window.location.hostname;
Tipped.create('.phpc-event-list a',{
ajax: {
url: sdomain+'/calendar/sources/event.php',
type: 'post',
data: {getEvent: 1, vid: $(this).attr('data-id')},
skin: 'light',
size: 'large',
radius: false,
position: 'topleft'



  • edited February 2016
    When you call $(this) there, 'this' just refers to the scope you are in at that point. Which is the same scope as when you'd call it above Tipped.create. Scope would only change within a different function, like a callback, but you're not using that. In your example, there's only one scope and the same 'this' value everywhere.

    If you need a scope, use a function that binds it or has what you need as a parameter.
    $('.phpc-event-list a').each(function(i, element) {
    console.log(element); // same thing, just more descriptive

    var id = $(element).attr('data-id');
    Tipped.create(element, { .. do something with id .. });
    Also make sure you are using the latest version of Tipped. The cache option is no longer part of the ajax object in more recent versions. It should be one level higher.
Sign In or Register to comment.