Namespace in Javascript con Jquery

1 ° estendere Jquery con la seguente funzione

jQuery.namespace = function() {
    var a=arguments, o=null, i, j, d;
    for (i=0; i<a.length; i=i+1) {
        d=a[i].split(".");
        o=window;
        for (j=0; j<d.length; j=j+1) {
            o[d[j]]=o[d[j]] || {};
            o=o[d[j]];
        }
    }
    return o;
};

2° Esempio di utilizzo

$.namespace( 'jQuery.debug' );
$.debug.test1 = function()
{
    alert( 'test1 function' );
};
 
$.debug.test1();

posted @ giovedì 8 luglio 2010 18:19

Print

Comments on this entry:

# re: Namespace in Javascript con Jquery

Left by Jade Sale at 20/09/2011 13:47
Gravatar
the thomas sabo charms sale rural teachers measures: in parts of the country to carry out the pilot reform of primary and secondary teachers titles, the highest title of the primary and secondary school teachers from the secondary jade sale are senior and middle thomas sabo watches to senior; law to protect teachers' average wage level is not below the national average ge of civil servants, and gradually increase; to speed up construction of rural Jade Jewelry teachers

# Mulberry Vesker

Left by Mulberry Vesker at 08/12/2012 06:12
Gravatar
kke bare fra Jinan søk er det forbrukerne spesielt kom til å delta i denne hendelsen fra Liaocheng, Tai'an,

# re: Namespace in Javascript con Jquery

Left by http://www.prosignal-auteuil.fr at 20/08/2015 12:33
Gravatar
Query.namespace = function() {

var a=arguments, o=null, i, j, d;

for (i=0; i<a.length; i=i+1) {
Comments have been closed on this topic.
«aprile»
domlunmarmergiovensab
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011