Skip to content

Buttons disable timeout config #193

thomasf1 opened this Issue Mar 14, 2014 · 1 comment

2 participants


I´m trying to add an undo button or link to a notification. (Inspired by item 8).

It seems noty ignores the timeout supplied when a button is set (which in most cases makes sense, just not in my use-case). Not sure that´s intentional or not. A workaround is to close the noty by ID with a setTimeout.

x = noty
  text: "Item y deleted"
  timeout: 2000 #Doesn´t work
  buttons: [
      addClass: "btn btn-primary"
      text: "undo"
      onClick: ($noty) ->
          text: "Delete aborted"
          type: "success"
          timeout: 1000

#works - delay is a helper function that calls setTimeout with reversed params (much nicher in coffee)
delay 2000, ->

I´ve worked around that now with a template. Works well, looks subtle.

aborted = false

x = noty
  text: msg
  timeout: timeout
  type: type
  template: '<div class="noty_message"><span class="noty_text"></span><a style="float:right">undo</a><div class="noty_close"></div></div>',
    afterClose: ->
      unless aborted

x.$message.find("a").click ->
  aborted = true
    text: undoMsg
    type: undoType
    timeout: 1000
@needim needim closed this Dec 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.