• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Get membercard HTML with onclick event

CrispinP

Well-known member
#1
Hi folks,

I'm struggling to work out how to customise the OverlayTrigger / ajax call to just return the html so I can use it.
I have an add-on I have just finished - see here and here for the examples.

I want to display the member car from an onclick event and not from an href.

Having watched Kier's tutorials it's pretty straightforward if you have a normal href but I can't work out if there is an equally as simple way to get the HTML or to display it on the map.

Here is what I have to work with:
Code:
var iw = new gm.InfoWindow();
oms.addListener('click', function(marker, event) {
iw.setContent('<a href="members/' + marker.user_name + '.' + marker.user_id + '">View details about ' + marker.user_name + '</a>');
iw.open(map, marker);
});
I don't have to use the InfoWindow - I can attach any onclick event and do what I want with it.


Thanks

Crispin
 

CrispinP

Well-known member
#2
Nobody got any tips? I've tried a few more things and cannot seem to trigger the member card from within the map.
 

rellect

Well-known member
#3
I assume you're looking for something like this
HTML:
oms.addListener('click', function(marker, event) {

    XenForo.ajax('members/127502', {
        card: 1
    }, function(ajaxData)
    {
        if (XenForo.hasTemplateHtml(ajaxData))
        {
            new XenForo.ExtLoader(ajaxData, function(ajaxData)
            {
                if (ajaxData.templateHtml)
                {
                    var html = ajaxData.templateHtml;
                    // do something with html..
                }
            });
        }

    }, {type: 'GET'});

});
 

CrispinP

Well-known member
#4
Thanks for that - I was so close. I was getting the html but for the whole member page, not the card. I've added that in now.

Don't suppose you know how to invoke the stock standard member card? ;)

upload_2016-6-3_23-6-45.png

this one.

That would be first prize :)
 

rellect

Well-known member
#5
HTML:
overlay = new XenForo.OverlayLoader($('<a href="members/127502?card=1" />'), true, {});
overlay.load();
 

CrispinP

Well-known member
#6
top man! (lady!) Thanks!

Works like a dream.


How did you know that? I trawled through the code, other add-ons etc and could find nothing to suggest that.

Or did you just work it out?