I agree with the other respondents... rather create your own
"namespace" and encapsulate your functions there.
e.g.
var myApp = { };
myApp.myTestFunction = function (param1) {
alert(param1);
}
myApp.myTestFunction('my function!');
Actually, don't listen to me :) look at a few of Crockford's video's
and the patterns he talks about. I especially like the following
example that allows you very easily build contained "modules" using
the correct scopes. (source:
http://javascript.crockford.com/code.html)
var collection = (function () {
var keys = [], values = [];
return {
get: function (key) {
var at = keys.indexOf(key);
if (at >= 0) {
return value[at];
}
},
set: function (key, value) {
var at = keys.indexOf(key);
if (at < 0) {
at = keys.length;
}
keys[at] = key;
value[at] = value;
},
remove: function (key) {
var at = keys.indexOf(key);
if (at >= 0) {
keys.splice(at, 1);
value.splice(at, 1);
}
}
};
}());
On Nov 9, 6:27 pm, "marty.mcgee" <
mcgee.ma...@...> wrote:
> Hello, Marty McGee here. I was hoping to open a discussion about the
> benefits of extending jQuery with your own custom functions versus
> simply writing your functions in JavaScript and calling them without
> extending jQuery first. Please enlighten me and the rest of the
> humble jQuery library addicts. Thanks to all.
>
> For example, this:
>
> $(function(){
> $.function_name = function test() {
> alert('in function');
> }
>
> });
>
> Versus this:
>
> $(function(){
> test();
>
> });
>
> function test() {
> alert('in function');
>
> }
>
> -------------------------------------------------------------