enyo / opentip

Opentip is an open source javascript tooltip based on the protoype framework.
http://www.opentip.org
1.25k stars 401 forks source link

Opentip does not update the fresh content via function #9

Closed ausblife closed 11 years ago

ausblife commented 11 years ago

I using a function to call the Opentip via javascript the function is called when a required field of a form via submit is empty, then the function is called to show the right content for the right field.

the problem I am having is that the content is not updating correctly, the problem itself is that the first content "the field cannot be empty" is showing right but when the field is not a valid email the second message instead of showing "the entered email is not a valid email address" is not showing but it is still showing the "the field cannot be empty" instead of "the entered email is not a valid email address".

I think is that the tooltip is not updating the new content but showing the previous content instead all the time.

Is there a way to show the fresh content all the time? I have not found a solution yet so I think this is an issue!!

I will appreciate your reply and solution! thanks

enyo commented 11 years ago

I'm currently working on v2 that will support that. For now you should disable the old, and create a new open tip when the content changes.

ausblife commented 11 years ago

Thank you for your kind reply! I wonder how to disabled the old so when creating the new one it is showing only the fresh content for the same form field. In this case it is the email form field that has two validations! one for empty field and second for invalid email format so I want to show always the fresch right content when updating the error message. I appreciate your kind reply about to disable the old one! best regards Andre's

Date: Mon, 1 Oct 2012 01:34:30 -0700 From: notifications@github.com To: opentip@noreply.github.com CC: ausblife@hotmail.com Subject: Re: [opentip] Opentip does not update the fresh content via function (#9)

I'm currently working on v2 that will support that. For now you should disable the old, and create a new open tip when the content changes.

          —

          Reply to this email directly or view it on GitHub.
enyo commented 11 years ago

Ok. In that case I would suggest you create two opentips. One that is used for Required and one for Invalid email. They should both have the config showOn = null so they never show automatically!

You store those two opentips objects in two separate variables like this:

var requiredTooltip = Tips.add("#your-element", "Email is required.", { showOn: null });
var invalidEmailTooltip = Tips.add("#your-element", "Please provide a valid email address.", { showOn: null });

Then in your validation code, you handle the opentips programmatically like this:

if (inputIsEmpty) { requiredTooltip.show(); }
else if (emailIsInvalid) { invalidEmailTooltip.show(); }

Something like this...

Hope that helped!

Cheers.

ausblife commented 11 years ago

thanks let you know if that worked! thanks a lot!

Andre's (R.A.P.)ausblife@hotmail.com

Date: Mon, 1 Oct 2012 06:28:24 -0700 From: notifications@github.com To: opentip@noreply.github.com CC: ausblife@hotmail.com Subject: Re: [opentip] Opentip does not update the fresh content via function (#9)

Ok. In that case I would suggest you create two opentips. One that is used for Required and one for Invalid email. They should both have the config showOn = null so they never show automatically!

You store those two opentips objects in two separate variables like this:

var requiredTooltip = Tips.add("#your-element", "Email is required.", { showOn: null }); var invalidEmailTooltip = Tips.add("#your-element", "Please provide a valid email address.", { showOn: null });

Then in your validation code, you handle the opentips programmatically like this:

if (inputIsEmpty) { requiredTooltip.show(); } else if (emailIsInvalid) { invalidEmailTooltip.show(); }

Something like this...

Hope that helped!

Cheers.

          —

          Reply to this email directly or view it on GitHub.
ausblife commented 11 years ago

Hello Mathias! I just wanted to let you know I found a solution!, now it refresh perfect everything!! you solution didnt work for me but this one yes! I think you could fix this in your code!

1) I create a style like this

Opentip.styles.myStyle = {
  className: 'slick',
  showOn: 'creation',
  hideOn: 'click',
  stem: true,
  stemSize: 15,
  delay: false,
  tipJoint: [ 'left', 'top' ],
  target: true,
  targetJoint: [ 'right', 'top' ],
  showEffect: 'blindDown',              };  

2) In the function instead of using $(id).addTip(content, {style: 'myStyle'}); I use this below:

function tooltip(id,content){Tips.list.invoke('hide');Tips.add(id, content, {style: 'myStyle'});} 

This works perfect and refresh the content all the time!! maybe the error it is when using this form:

function tooltip(id,content){Tips.list.invoke('hide');$(id).addTip(content, {style: 'myStyle'});}

This last one does not refresh content and showing always last tooltip created!

NOTE: (addTip does not work properly like Tips.add) maybe a small bug to take a look and done! I think it will be easier for you to fix it!! Thanks for everything!Best regardsAndre's