Message on-click action

  • 1
  • Question
  • Updated 4 years ago
  • Answered
I use "editor.handleMessages()" a lot to show messages to the users. If a user clicks on the message, it simply goes away. Some users think that this somehow fixes the error (yes I know it's funny...). It would be great if clicking on the message could run a snippet or redirect them to a page to fix the problem. Is there a way to do this?
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Interesting question :)

Can you set up a jquery onclick event handler?
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
Possibly, but I don't know how to set a unique ID for the actual message that gets displayed.
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Create an inline JS resource using this code:

(function(skuid) {
var $ = skuid.$;

// Run the snippet initially on page load
$('.nx-page').one('pageload', function() {
$('.nx-messages').on('click', function(){
alert('Hello World!');
});
});
})(skuid);

Does this get you closer?
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
That actually works! I inspected the element and I got ".nx-error" which I believe is even more specific than ".nx-messages".