estum / growlyflash

Growl-styled flash messages for Ruby on Rails and Bootstrap
MIT License
58 stars 34 forks source link

Flash messages with xhr break in Rails 5.1.5 #45

Open nflorentin opened 6 years ago

nflorentin commented 6 years ago

Hi,

Flash messages with xhr no longer works in Rails 5.1.5 because of the following:

Like this page said: As of Rails 5.1 and the new rails-ujs, the parameters data, status, xhr have been bundled into event.detail. For information about the previously used jquery-ujs in Rails 5 and earlier, read the jquery-ujs wiki.

I think the reason is that the following code no longer works (in Listener class):

 constructor: (context) ->
    @stack ?= new Stack()
    @process_static(context)
    ($ context).on Growlyflash.Listener.EVENTS, (event, xhr) =>
      if xhr ?= event.data?.xhr # now returns false 
        source = process_from_header(xhr.getResponseHeader(Growlyflash.Listener.HEADER))
        @stack.push_only_fresh source
      return

As a quick fix, I patch that method removing the test but I don't know if it could produce any side effect...

serggl commented 6 years ago

this might be related to a typo I found in #47