HubSpot / messenger

Growl-style alerts and messages for your app. #hubspot-open-source
http://github.hubspot.com/messenger/
MIT License
4.03k stars 408 forks source link

How to show actions only on success (ajax) #111

Open misner opened 8 years ago

misner commented 8 years ago

On my app, when user sees the modal, he first sees 'loading' while the app gathers something we call the Result.

Then if ajax returns a 'success', I want to show 2 action buttons ('get more details about result') and 'go back to next result')

var msg;
msg = Messenger().run({
  action: $.ajax,
  progressMessage:  'Loading the RESULT...',
  successMessage:  'This is the Result : %{results  and all}',
   actions: {
      getMoreDetails: {
        label: "give me details on the provided result",
        action: function() {
          ....//do stuff
        }
      },
      goToNextResult: {
        label: 'Move To Next Result',
        action: function(){
         //do stuff
        }       
      }
    }
});

The problem today is that the app shows the 2 action buttons ('get more details' and 'move to next result' ) while showing 'loading', that is to say before even showing to the user the result.

Is it possible to tell Hubspot Messenger to only show the actions when the 'success' ajax message appears ?