Not really. I think that would have the effect (in that you'd no longer see
the tip) but you'd be better off detaching all the elements you attached to:
var myTips = new Tips($$('.tips'));
...
myTips.detach($$('.tips'));
It's been on my (long, long, long) list of things to do to go through all
the -more plugins that attach to elements and add a destroy method that
knows how to clean itself up. For now, you have to use detach this way.
On Wed, May 5, 2010 at 1:58 AM, hamburger <[email protected]> wrote:
> does it also mean that i can kill an instance of a class with
> var myTips = new Tips(...);
> $(myTips).dispose();
>
> ??
>
>
> On 4 Mai, 12:05, hamburger <[email protected]> wrote:
> > Thanks Aaron,
> > the reference to my Tips with $(myTips).fade('out');
> > is what i was looking for.
> >
> > Thanks Stratboy,
> > but with so much efforts i put in understanding the Tips-Class i will
> > keep on with this stuff
> >
> > until now i could not find an error there. The error was always me ...
> >
> > great work for the mootools team
> >
> > On 4 Mai, 08:31, stratboy <[email protected]> wrote:
> >
> >
> >
> > > Tips has a number of problems. I wrote another Tooltips class for me
> > > and it works just well. It's very basic, but simple. So you can expand
> > > it quite easily. Feel free to use it.
> >
> > > *******
> > > var Tooltips = new Class({
> >
> > > Implements:[Options,Events],
> >
> > > options:{
> > > className:'tip-box',
> > > offset: {x: 16, y: 16}
> > > },
> >
> > > //id is intended just as 'identifier', not html id, so it can
> be
> > > anything, a class or so
> > > initialize: function(id,options){
> > > this.setOptions(options);
> > > this.id = id;
> > > this.elements = [];
> >
> > > this.initElements();
> > > },//end init
> >
> > > initElements:function(){
> > > this.elements = $$(this.id);
> >
> > > this.elements.each(function(elem,index){
> > > this.buildTip(elem);
> > > },this);
> >
> > > this.elements.addEvents({
> > > 'mouseover':function(e){
> > > var t=($(e.target).match('a')) ?
> $(e.target) : $
> > > (e.target).getParent('a');
> > > this.showTip(t.retrieve('tip'));
> > >
> t.addEvent('mousemove',this.mouseTrack.bindWithEvent(this));
> > > }.bindWithEvent(this),
> >
> > > 'mouseout':function(e){
> > > var t=($(e.target).match('a')) ?
> $(e.target) : $
> > > (e.target).getParent('a');
> > > this.hideTip(t.retrieve('tip'));
> > >
> t.removeEvent('mousemove',this.mouseTrack.bindWithEvent(this));
> > > }.bindWithEvent(this)
> >
> > > });
> > > },
> >
> > > buildTip:function(element){
> > > var tip = new Element('div',{
> > > 'class':this.options.className,
> > > 'styles':{
> > > 'display':'none',
> > > 'position':'absolute'
> > > }
> > > });
> >
> > > var tipTop = new Element('div',{ 'class':'tip-top' });
> > > var tipBody = new Element('div',{ 'class':'tip-body'
> });
> > > var tipContent = new Element('div',{
> 'class':'tip-content' });
> > > var tipBottom = new Element('div',{
> 'class':'tip-bottom' });
> >
> > > tipContent.set('html',element.get('title'));
> > > element.removeProperty('title');
> > > tipBody.adopt(tipContent);
> > > tip.adopt([tipTop, tipBody, tipBottom]);
> > > tip.inject(document.body);
> >
> > > element.store('tip',tip);
> > > //todo: add effects
> > > },
> >
> > > mouseTrack:function(e){
> > > var t=($(e.target).match('a')) ? $(e.target) : $
> > > (e.target).getParent('a');
> > > var tip = t.retrieve('tip');
> > > tip.setStyles({
> 'left':e.page.x+this.options.offset.x,'top':e.page.y
> > > +this.options.offset.y, });
> > > },
> >
> > > showTip:function(tip){
> > > if(tip.getStyle('display') == 'none')
> > > { tip.setStyle('display','block') }
> > > },
> >
> > > hideTip:function(tip){
> > > if(tip.getStyle('display') == 'block')
> > > { tip.setStyle('display','none') }
> > > }
> >
> > > });
> >
> > > window.addEvent('domready',function(){
> > > var tips = new Tooltips('.thumb-tip');
> >
> > > });
> >
> > > *******
> >
> > > On 3 Mag, 14:22, hamburger <[email protected]> wrote:
> >
> > > > Hello in my code the function
> > > > Hints.detach(li_element);
> > > > destroys the detached element (here:li_element) not the Hints.
> >
> > > > is this the way of meaning?
> >
> > > > How to destroy the showed Tip-element?
> >
> > > > my code:
> > > > var li_element = new Element('li', {
> > > > 'id': bildID,
> > > > 'class': 'complain',
> > > > 'html': complaintext + '<br
> /><span class="time">I do not
> > > > want this ...</span>'
> > > > }).adopt(
> > > > new Element('img', {
> > > > 'class':
> 'complain-remove',
> > > > src:
> 'images/investor_close.gif',
> > > > title: 'click to
> remove.',
> > > > events: {
> > > > click:
> function() {
> >
> > > > Hints.detach(li_element); //Tip
> > > > delete
> > > > li_element.dispose();
> > > > }
> > > > }
> > > > })
> > > > ).inject('complainContainer','top');
> >
> > > > and for tips:
> >
> > > > var Hints = new Tips({
> > > > showDelay: 100,
> > > > hideDelay: 10,
> > > > offset: {
> > > > 'x': -60,
> > > > 'y': -130
> > > > },
> > > > fixed: true,
> > > > className: 'david_tip',
> > > > onShow: function(tip,el) {
> > > > tip.fade('in');
> > > > },
> > > > onHide: function(tip,el) {
> > > > tip.fade('out');
> > > > },
> > > > onDetach:function(tip,el) {
> > > > alert("detached");
> > > > //tip.fade('out'); //something wrong here
> > > > //tip.setStyle('display', 'none');
> > > > }
> > > > });- Zitierten Text ausblenden -
> >
> > > - Zitierten Text anzeigen -- Zitierten Text ausblenden -
> >
> > - Zitierten Text anzeigen -
>