1. 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

Discussion in 'XenForo Development Discussions' started by CrispinP, May 30, 2016.

  1. CrispinP

    CrispinP Active Member

    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:
    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.


  2. CrispinP

    CrispinP Active Member

    Nobody got any tips? I've tried a few more things and cannot seem to trigger the member card from within the map.
  3. rellect

    rellect Well-Known Member

    I assume you're looking for something like this
    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'});
  4. CrispinP

    CrispinP Active Member

    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? ;)


    this one.

    That would be first prize :)
  5. rellect

    rellect Well-Known Member

    overlay = new XenForo.OverlayLoader($('<a href="members/127502?card=1" />'), true, {});
  6. CrispinP

    CrispinP Active Member

    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?
  7. rellect

    rellect Well-Known Member

    I'm already familiar with the framework, but basically you want to find the source code of the function and understand how it works.
    CrispinP likes this.

Share This Page