Ralph Shnelvar
2012-Jan-01 19:14 UTC
Calling a function inside of (function($) {})(jQuery);
I have a .js file with the following function function set_priceKind_global(priceKind) { switch(priceKind) { case "paid": case "free": break; default: var throw_msg = "Internal confusion in set_priceKind_global" alert(throw_msg) throw throw_msg } It is triggered by %input{''type'' => ''button'', ''value'' => ''Free'', :onclick => ''set_priceKind_global("free")''} Because of conflicting libraries, I''d like to wrap set_priceKind_global thusly (function($) { // Lots of functions function set_priceKind_global(priceKind) { switch(priceKind) { case "paid": case "free": break; default: var throw_msg = "Internal confusion in set_priceKind_global" alert(throw_msg) throw throw_msg } })(jQuery); When I wrap it, Firebug reports that set_priceKind_global is undefined. How do I expose set_priceKind_global as a function that the onclick can trigger? Or, alternatively, modify the onclick so that the function can be called? Is there a javascript/jQuery forum that you can recommend? Ralph Shnelvar -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Craig White
2012-Jan-02 02:56 UTC
Re: Calling a function inside of (function($) {})(jQuery);
On Sun, 2012-01-01 at 12:14 -0700, Ralph Shnelvar wrote:> I have a .js file with the following function > > > function set_priceKind_global(priceKind) > { > switch(priceKind) > { > case "paid": > case "free": > break; > default: > var throw_msg = "Internal confusion in set_priceKind_global" > alert(throw_msg) > throw throw_msg > } > > > It is triggered by > %input{''type'' => ''button'', ''value'' => ''Free'', :onclick => ''set_priceKind_global("free")''} > > > > Because of conflicting libraries, I''d like to wrap set_priceKind_global thusly > > > (function($) { > // Lots of functions > > function set_priceKind_global(priceKind) > { > switch(priceKind) > { > case "paid": > case "free": > break; > default: > var throw_msg = "Internal confusion in set_priceKind_global" > alert(throw_msg) > throw throw_msg > } > })(jQuery); > > > > When I wrap it, Firebug reports that set_priceKind_global is undefined. > > > How do I expose set_priceKind_global as a function that the onclick can trigger? Or, alternatively, modify the onclick so that the function can be called? > > > > Is there a javascript/jQuery forum that you can recommend?---- I had really good experience w/ IRC (freenode, #jquery) and using jsfiddles.net for my code/example Craig -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sanjiv Jha
2012-Jan-02 04:52 UTC
Re: Calling a function inside of (function($) {})(jQuery);
Hi Ralph, May be you had not included jquery or included jquery after these code(or file in which these code is written)> > Regards,Sanjiv -- Josh Software Private Limited <http://www.joshsoftware.com> 6, Thube Park, Shivaji Nagar, Pune - 411005 Office: +91-020-25539995 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.