-1

I am implementing a growl notification system. Most of the scripts I checked are using a hide() method after the notification shows up. This makes the DOM persist inside the page after getting timedout. When we have a lot of notifications, the DOM count keeps on increasing. Can some one help me with this script, so that I can really remove the DOM element instead of setting a display:none?

script : http://iambot.net/demo/tinypop/tinypop-1.0.js

Thank you.

David G
  • 94,763
  • 41
  • 167
  • 253
user632347
  • 835
  • 2
  • 9
  • 21

2 Answers2

1

replace

// Hide the popup
hide: function() {
    fadeout.apply(this);
}

with

// Remove the popup
hide: function() {
    this.parentNode.removeChild(this);
}
st3inn
  • 1,556
  • 9
  • 17
  • tried this. but the dom and the content are still there – user632347 Nov 02 '12 at 15:44
  • What if you do the same in this part of the `var TINYPOP = ... ` function: `if( this.o.sticky ) { $("close"+count).onclick = function() { fadeout.apply(that); }; }` (i.e. replace `fadeout.apply(that)` with `that.parentNode.removeChild(that)`) – st3inn Nov 02 '12 at 15:47
  • can you tell me where should i try that? – user632347 Nov 02 '12 at 15:49
  • However, mucking about with the script like this can cause more problems because other parts of the script expect the element to still be in the DOM – st3inn Nov 02 '12 at 15:50
  • Sorry, problem still exist. tried that code too – user632347 Nov 02 '12 at 15:50
  • Open the script and do a Ctrl+F on "fadeout.apply" and change it to remove the element, but like I said, this can mess the rest of the functionality up. – st3inn Nov 02 '12 at 15:51
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/18981/discussion-between-user632347-and-batman) – user632347 Nov 02 '12 at 16:00
0

I don't have any experience of this particular script library but it seems to me that you could just rewrite the hide function within the prototype block at the bottom to this, which would remove the element from the DOM.

// Hide the popup
hide: function() {
    //fadeout.apply(this);
    this.parentNode.removeChild(this);
}

(You can't remove the element directly, according to this helpful SO answer Remove element by id, so you have to go to its parent and ask that to remove its child.)

Obviously this doesn't have any error checking (which it should!).

Community
  • 1
  • 1
Jon
  • 309
  • 3
  • 10
  • -corrected "element.parentNode.removeChild(element)" to "this.parentNode.removeChild(this)" – Jon Nov 02 '12 at 15:40
  • i tried it. But the dom and the content are still there – user632347 Nov 02 '12 at 15:43
  • do you get any script errors? are you sure you don't have the old version of the script cached in your browser? – Jon Nov 02 '12 at 16:34
  • Have you noticed that this question has been closed? Can't say I understand the reasons - I didn't find it "ambiguous, vague, incomplete, overly broad, or rhetorical". I'm pushed for time right now, will try a jsfiddle later if you haven't cracked it by then, – Jon Nov 02 '12 at 16:57
  • just one thing - if you're using a nice debugging console like firebug, you could try replacing the contents of the hide() function with "console.log(this);", just to check that "this" is what we think it is. – Jon Nov 02 '12 at 16:58