EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: kirschkern_1992 on July 12, 2013, 12:15:54 AM



Title: passing parameters to ajax tooltip
Post by: kirschkern_1992 on July 12, 2013, 12:15:54 AM
good morning

i have a short question:
i implemented an ajax tooltip. for my plan, i have to pass parameters to the ajax request of the tooltip, but i dont find a nice solution for this problem

thats my tooltip
Code:
<a class="easyui-tooltip" data-options="position: 'right', content: $('<div></div>'),onUpdate: infoTooltipOnUpdate" href="#">
<img alt="info_icon.png" src="http://saleslink.local/backend/img/info_icon.png">
</a>

onupdate function:
Quote
function infoTooltipOnUpdate(content){
    content.panel({
       width: 300,
       height: 'auto',
       border: false,
       href: ajaxUrl + '?PARAM1=123&PARAM2=456&PARAM3......'
   });
}

the tooltip is in a grid. for each row in the grid, an tooltip-icon exists. so for each grid row other content should be shown.
to realize that, i have to pass parameters to the tooltip-request, but i dont find a nice solution

i solved the problem with an attribute in the tooltip:
Code:
<a class="easyui-tooltip" data-options="position: 'right', content: $('<div></div>'),onUpdate: infoTooltipOnUpdate" href="#" param1="123">
<img alt="info_icon.png" src="http://saleslink.local/backend/img/info_icon.png">
</a>

Quote
function infoTooltipOnUpdate(content){
      var param1 = $(this).attr('param1');
    content.panel({
       width: 300,
       height: 'auto',
       border: false,
       href: ajaxUrl + '?PARAM1=' + param1
   });
}


does anyone know an better solution?

thx for help


Title: Re: passing parameters to ajax tooltip
Post by: stworthy on July 12, 2013, 01:48:33 AM
You can add customized property in 'data-options' attribute.
Code:
<a class="easyui-tooltip" data-options="position: 'right',onUpdate: infoTooltipOnUpdate, param1:'123'">
...
</a>
And then call tooltip's 'options' method to get your added properties.
Code:
function infoTooltipOnUpdate(content){
  var opts = $(this).tooltip('options');
  var param1 = opts.param1;
  alert(param1);
  //...
}


Title: Re: passing parameters to ajax tooltip
Post by: kirschkern_1992 on July 12, 2013, 05:22:39 AM
ok thx for other solution :D