Topic: How to use toast in meteor environment (MD3)

dongzhi.yang@bonuspoint.info pro asked 8 years ago


I am on MD3 and trying to use toast.js The problem is I found that i can't use toastr object directly. I did some investigation and found that the toastr object is not associated with 'window'. here is the last lines of code in toast.js, I assume it decides where toastr object is associated.I have added 2 console.log in the 2 branches of if. ----------------------------- (typeof define === 'function' && define.amd ? define : function (deps, factory) { if (typeof module !== 'undefined' && module.exports && typeof require === 'function') { //Node module.exports = factory(require('jquery')); console.log("hello 1"); } else { window['toastr'] = factory(window['jQuery']); console.log("hello 2"); } }) ------------------------------ the console returns "hello 1". so obviously window['toastr'] never execute. I am in a Meteor environment on top of node.js jquery. could you let me know how to use toastr in this case? thanks. Regards Don

Hi Dawid, The problem with toastr is that they don't reply. I think this should be an simple question, because I see other people using toastr in the same environment as I use. I just not very familiar with the following code (i think they are written for node.js", especially the keywords 'define', 'require','factory' etc. I hope someone can help me understand it. So I can figure out how it works. Thanks & Regards Don ------------------- (typeof define === ‘function’ && define.amd ? define : function (deps, factory) { if (typeof module !== ‘undefined’ && module.exports && typeof require === ‘function’) { //Node module.exports = factory(require(‘jquery’)); console.log(“hello 1”); } else { window[‘toastr’] = factory(window[‘jQuery’]); console.log(“hello 2”); } })

Dawid Adach pro answered 8 years ago


@dongzhi.yang@bonuspoint.info Toast.r is separate library. I was about to raise an issuedirectly on project page on github, however I noticed that you have already done that. Let's wait for a response from creators. https://github.com/CodeSeven/toastr/issues/421

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags