Problem With qTip2

http://cdn.discourse.org/sitepoint/uploads/default/21611/8826f80d5959285d.png

@Jeff_Mott that’s kinda the thing I hope to do, with the info about the user varying depending on the user’s status on the site and the privileges of the person viewing the info. With the toolip opening when the user name is clicked on and only closing when the close icon or text is selected.

When I use qtip firebug lists a load of errors, I’m going to try and fix them, and see if that changes the situation

Is that not effectively what Discourse does when you click on someone’s user name?

Probably most forums software do something similar

Hi Jeff,

It’s how you set up the fiddle. You should put the HTML and JS in different panes, as well as include the external resources in thecorrect place.

Here is a working version of your demo.

1 Like

I’m starting to get somewhere with this now, the following is at least attempting to grab the JSON data:

  $(document).ready(function() {
    console.log('document ready');
    
    $('a.user[title]').each(function() {
        console.log('a.user[title]', this );
        
        $(this).qtip({
            show: "click",
            hide: false,            
            content: {
                text: function(event,api) {
                    console.log('qtip content text');
                    
                    $.ajax({
                        
                        url: 'http://localhost/universal_empires/api/get_user_infobox',
                        data: {
                            id: $(this).data('id')
                        },
                        dataType: 'json',
                        type: 'POST'

                })
                .done(function(content) {
                    api.set('content.text',html);
            })
                .fail(function(xhr,status,error) {
                    api.set('content.text', status + ': ' + error); 
            });            
                return 'Loading...';
            },
            
            button: 'Close'
        },
                  position: {
                      viewport: $(window)
                  },
                  style: 'qtip-wiki'
            });
      });

$("a.user").on("click", function(e){
    e.preventDefault();
});
});

Is there a way to either have firebug display what has been received or “dump” the received JSON data into an alert?

EDIT: The qtip tooltip displays:

parsererror: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

Don’t use alerts. That’s a world of pain.

.done(function(content) {
  console.log(content);

@Pullo no luck with that - with firebug open as soon as I click on the tooltip after first refreshing it’s crashing FF everytime :frowning:

I’m afraid we’re back to the point when I would need to see a working demo.

Whoops! Was trying to use the wrong url :blush: from checking the firebug console the json data is received back ok, will look at the usage of the json data at the weekend

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.