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 S.

On Sun, 2012-01-01 at 12:14 -0700, Ralph S. wrote:

default:

case “paid”:

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.

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs