You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

Dynamic hint change? Created Sep 8, 2009

This thread is solved

Views: 5347     Replies: 13     Last reply Dec 1, 2011  
You must login first before you can use this feature

bercium

Posts: 8

Registered:
Sep 8, 2009

Dynamic hint change?

Posted: Sep 8, 2009

Is it possible to change hint dynamically.
For example we have a toggle button like minimize/restore, where at the beginning hint should say 'minimize' and after clicking it should say 'restore'.
I have tried to set the title attribute again and calling tooltip() function for that element but it doesn't work (it used to work in previous version)

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1867

Registered:
Nov 16, 2007

» Dynamic hint change?

Posted: Sep 9, 2009

Reply to: Dynamic hint change?, from bercium
If you are using title attribute you can do following:


$("#mytrigger").data("title", "My new tooltip");

Also look for the cancelDefault variable from the configuration:

http://flowplayer.org/tools/tooltip.html#configuration

If you are using separate element as your tooltip (which I doubt here) you simply change it's content as follows


$("#mytooltip").html("My new tooltip");

bercium

Posts: 8

Registered:
Sep 8, 2009

» » Dynamic hint change?

Posted: Sep 9, 2009

Reply to: » Dynamic hint change?, from tipiirai
Thank you for your replay, but I've also tried changing data attribute (title) with no success. I know about cancelDefault and if I disable it default attribute is shown correctly while tooltip still shows first value.
If I try changing title attribute then default tooltip apears since title isn't removed by tooltip script. Even if I call tooltip() function again after setting title with data or just with attribute nothing changes.

Here is the example of script I use (with added alert to show values). But tooltip still doesn't change.

.click(function(){
  if (...){
    $(this).data("title","Default text");
    //$(this).attr("title","Default text");
    //$(this).tooltip(tooltip_opts);
  }else{
    alert($(this).data("title"));  // outputs: default text
    $(this).data("title","Changed text");
    //$(this).tooltip(tooltip_opts);
    alert($(this).data("title"));  // outputs: changed text
  }

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1867

Registered:
Nov 16, 2007

» » » Dynamic hint change?

Posted: Sep 9, 2009

Reply to: » » Dynamic hint change?, from bercium
You are right about this. I need to change the behaviour to alter dynamic changes. 1.1.1. should be out within two weeks.

bercium

Posts: 8

Registered:
Sep 8, 2009

» » » » Dynamic hint change?

Posted: Sep 9, 2009

Reply to: » » » Dynamic hint change?, from tipiirai
Thanks

blissofbeing

Posts: 2

Registered:
Aug 6, 2010

» » » » Dynamic hint change?

Posted: Aug 6, 2010

Reply to: » » » Dynamic hint change?, from tipiirai
This still doesn't seem to be working, can you confirm?

arwoPL

Posts: 2

Registered:
Oct 22, 2010

» Dynamic hint change?

Posted: Oct 22, 2010

Reply to: Dynamic hint change?, from bercium
try this, but its not AJAX :)

onBeforeShow: function(){
	if (this.getTrigger().attr('title') != '') {
		this.getTip().text( this.getTrigger().attr('title') );
	}
}

In other place You change title attribute, example:

$('input[name=XXX]').attr('title','Blablablabla.');

tinyrhino

Posts: 1

Registered:
May 23, 2011

» » Dynamic hint change?

Posted: May 23, 2011

Reply to: » Dynamic hint change?, from arwoPL
Thank you arwoPL, your solution works!

There is just one thing: the browser now displays the default tooltip because the trigger element has a title attribute again.

By clearing the title attribute after the value has been stored in the tooltip text, you will have the desired outcome.


onBeforeShow: function(){
     if (this.getTrigger().attr('title') != '') {
          this.getTip().text( this.getTrigger().attr('title') );
          this.getTrigger().removeAttr('title');
     }
}

It would be a lot more convenient if the tool were actually fixed to work as documented (i.e. simply changing .data("title")), but for now this solution works. Thank you for your post!