It looks like you're new here. If you want to get involved, click one of these buttons!
Macro.add("message", { tags : null, handler : function () { var type = 'link'; var link = 'Help'; var id = this.args.join(); var message, el, jqSel; id = id.replace(/[^A-Za-z0-9]/g, ''); if (this.args.includes('btn')) { type = 'button'; } if (this.args[0] !== 'btn' && this.args.length !== 0) { link = this.args[0]; } if (type === 'link') { jqSel = '#macro-message-' + id + ' a'; } else { jqSel = '#macro-message-' + id + ' button'; } //output link = '<div class="help" id="macro-message-' + id + '"><<' + type + ' "' + link + '">><</' + type + '>></div>'; message = link + this.payload[0].contents; el = '#macro-message-' + id; $(this.output).wiki(link) .on('click', jqSel, function () { if ($(el).hasClass('open')) { $(el).empty().wiki(link).removeClass('open'); } else { $(el).empty().wiki(message).addClass('open'); } }); } });
<<message>>blah blah blah<</message>>
Some text. <<message "Click for information!">>Here's some information!<</message>> More text.
Some text. Click for information! More text.
Some text. Click for information! Here's some information! More text.
Comments
Beyond that. If you want an anchor or a button, simply use the standard elements. Incorporating a <<link>> or <<button>> macro for the sole purpose of mugging them for the element they create is daft.
Finally. Since you're creating the elements, there's no need to attach the handler to the wrapper and using a delegate selector to target the link element. You may simply attach the handler to the link element itself.
Try something like the following:
I'm still having a bit of trouble completely wrapping my head around jQuery, but I'm getting there. I really appreciate the help, especially how detailed your explanations are. You're a national treasure, TME.