EasyUI Forum
May 02, 2024, 06:25:38 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: passing parameters to ajax tooltip  (Read 8965 times)
kirschkern_1992
Newbie
*
Posts: 2


View Profile Email
« 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
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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);
  //...
}
Logged
kirschkern_1992
Newbie
*
Posts: 2


View Profile Email
« Reply #2 on: July 12, 2013, 05:22:39 AM »

ok thx for other solution Cheesy
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!