I'm working on some tooltip functionality on my site again.
The manifest module pattern as shown here:
As a quick test, I tried it:
< Code> var tooltip = function () {var foobar = 'foo bar'; Function getAlerter () {return warning (foobar); } Return {alerter: getAlerter}} (); Tooltip.alerter (); Which alert is expected of 'foo and bar'.
However, I have to pass the element that triggered the tooltip functionality:
var tooltip = function (AMM) {var triggers = AMM; Function getAlerter () {return warning (trigger); } Return {alerter: getAlerter}} (); Tooltip.alerter ('trigger'); But this return is unscheduled why it is not sure: (
< P> This is because you are executing the function ( () at the end of your 'module'), and when your function is declared and executed, no value passed You can tell your getAlerter function to accept additional parameters: function getAlerter (triggers) {// you Greater code ...} But it questions the entire information behind your pattern. If you want to allocate your module with one element, you get the most Something like this should end in:
var tooltip = function (elem) {// your entire module code ...} ('trigger'); Or, if you want many examples, remove () at the end of your 'module', and run it like this: var MyTooltip = tooltip ('A Lerter '); myTooltip.alerter (); For example, if you want to keep it as a single, you can easily add init method: < Code> var tooltip = function (amm) {var triggers; Function getAlerter () {return warning (trigger); }; Function Init (AMM) {Trigger = AMM; } Return {alerter: getAlerter, init: init}} (); And run it like this:
tooltip.init ('. Alerter'); Tooltip.alerter ();
Comments
Post a Comment