Call variables from jQuery in javascript -


How can I call the variables defined in jQuery when working in JavaScript? Basically, I have this:

  (function ($) {function giveVariables () {var foo; var bah; $ (document) .bind ('stuff', function (e, superFoo , Superbah) {foo = superFoo; ba = superbah;}); return {FOP: af, bahpi: swept}}}) (jQuery); Function needed Variables () {var requiredVars = giveVariables (); FOP = Required Vars.fop; PA = Vars.bahp = Required; * Code which uses the variable I pass *}   

Obviously, this does not pull the variable. It's telling me that the deviables are undefined, but I'm not sure why I I'm a little new, so any information on everyone will be helpful.

You defined foo and bah It is not available for that work, it is easy as it is needed. If you want to deliver, where you need this, then you have to define them in those places where it will be accessible.

  // {function giveVariables () {var foo; var bah; $ (document) .bind ('stuff', function (e, superfu, superbah) {Foo = superFoo; bah = superBah;}); return {FOP: af, bahpi: bah}}) (jQuery); Function needed Variables () {var requiredVars = giveVariables (); FOP = Required Vars.fop; PA = Vars.bahp; * Code that uses variable I pass *}   

If you want to keep iife as originally, then you have to attach your dynamical function to the window Have to do. / P>

  (function ($) {function giveVariables () {var foo; var bah; $ (document) .bind ('stuff', function (e, superFoo, superBah) {foo = superFoo; Bah = superBah;}); return {fop: foo, bahp: bah}} window.giveVariables = deviables;}) (jQuery); Function Requirements (Variables) (VAR Required Vars = giveVariables (); FOP = Required Vars.fop; Bap = Required Vars.bahp; * Code which uses variable I pass *}   < / Div> 

Comments

Popular posts from this blog

How can I add a seperate action listener to all 14 of my buttons at once that can determine player turn?(java) -

php - Sorting an multidimension array using usort fails -

Simple file compression in C -