Howdy, Stranger!

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

Using Tipped with jQgrid Ajax calls

Hi

I am using Tipped within jQgrid. Each line of the grid has an information button that use the Tipped ajax call to get dynamic data in relation to each line.

Everytime the grid is refreshed, the ajax calls are increased by 1. So on the frist page load, only 1 ajax call is made as desired. Each time the grid is reloaded the calls increase. So on the second refresh 2 ajax calls are made, on the third 3 calls and so on.

I have tried to use the tipped.remove('.myClass') every time the function is called that attaches the information Tipped functionality.

I have also updated to the latest version and this did not help.

Any help would be most welcome.

Here is some of the code which I use to create the Tipped :

function attachInfo(){

    Tipped.clearAjaxCache();

    Tipped.remove('.contract_tip');

    // **** info functions  
    Tipped.delegate('.contract_tip', {
        ajax: {
            url: 'tooltip.tip_contractInfo',
            type: 'post',
            data: $(this).closest('tr').attr('id'),
            cache: false,
            success: function(data, textStatus, jqXHR){
                this.update({
                    title: 'Contract Information',
                    content: data
                });

                return false;
            }
        },
        skin: 'light',
        radius: true,
        position: 'bottomleft',
        showOn: 'click',
        voila: false
    });

}

AND PART OF THE GRID CODE
...
gridComplete: function(){
addPrettyPhotoForms();
attachInfo();

    }

...

Comments

  • It's ok I think I have found a solution. I should use Tipped.create instead of Tipped.delegate.

    Thanks

  • edited October 2016

    Yes, that would work. Or you could add Tipped.undelegate() to stop delegation on the selector before you delegate again.

    The most optimal way would be writing this so that you only call Tipped.delegate() once and call Tipped.remove() on elements that have a tooltip right before you remove them from the DOM.

    Tipped.delegate() only needs to be called once, calling it multiple times on the same selector would create duplicate tooltips. So that explains the stacking ajax requests.

    Writing it that way could be a bit tricky in this case. Using Tipped.create() should be easier.

Sign In or Register to comment.