To jQuery je mozne aby bol kod aj v externom subore? Ja som to skusal a neslo a na nete som to nenasiel(aj ked moc som to nehladal) Nasiel som ale na nete funkcie kt. splnaju to co chcem a dokazem si ich upravit tak aby fungovali ale prvej chapem asi ako hus konstrukcii raketoplanu. Tak sa pytam neslo by to jednoduchsie alebo mohol by mi pls niekto zhruba vysvetlit co to robi.
Tomuto nechapem :)
/* Emulation module that allows multiple listeners to be attached to a single
* element, even on browsers that do not support the W3C DOM 2 Events
* specification.
*
* Exposed interfaces:
* addEventListener(o, t, l)
* o - Reference to the object where the listener should be attached.
* t - Type of events to intercept ('on' prefix must be omitted).
* l - Reference to a function that will act as a listener.
*
* removeEventListener(o, t, l)
* o - Reference to the object from which the listener should be detached.
* t - Type of events intercepted ('on' prefix must be omitted).
* l - Reference to the listener to be removed.
*/
var domEvents = (function() {
function isF(o) {return 'function' == typeof o;}
function isO(o) {return o && ('object' == typeof o || isF(o));}
function isS(o) {return 'string' == typeof o;}
var DF = (function() {
var s = {};
function DN(d) {
var n = null, p = '__faked_call_property';
this.a = function(v) {if(n) {n.a(v);} else {n = new DN(v);}};
this.f = function(o, e) {
var r; o[p] = d; r = o[p]();
if(n) {return n.f(o, e) || r;}
return r;
};
this.r = function(v) {
if(d == v) {return n;} else if(n) {n = n.r(v);} return this;
};
}
function isI(o) {return o.s == s;}
return ({
aL : function(o, t, l) {
var f = o[t = 'on' + t], n = null;
function D(e) {
var r = true; if(n) {r = n.f(o, e || window.event);} return r;
}
D.a = function(v) {if(n) {n.a(v);} else {n = new DN(v);}};
D.r = function(v) {if(n) {n = n.r(v);}};
D.s = s;
if(!f || !isI(f)) {o[t] = D;}
if(isF(f) && !isI(f)) {o[t].a(f);}
o[t].a(l);
},
dL : function(o, t, l) {var f = o['on' + t]; if(isI(f)) {f.r(l);}}
});
})();
return ({
addEventListener : function(o, t, l) {
if(isO(o) && isS(t) && isF(l)) {
if(o.addEventListener) {o.addEventListener(t, l, false);}
else {DF.aL(o, t, l);}
}
},
removeEventListener : function(o, t, l) {
if(isO(o) && isS(t) && isF(l)) {
if(o.removeEventListener) {o.removeEventListener(t, l, false);}
else {DF.dL(o, t, l);}
}
}
});
})();
Tieto som si uz upravil podla potreby(ale to by uz zvladla aj cvicena opica)
function showId() {
alert(this.id);
return false;
}
/* This code doesn't follow best practice!
* DOM methods and objects should be tested before use.
*/
domEvents.addEventListener(this, 'load', function() {
var d = document.getElementById('demo'),
l = d.getElementsByTagName('A');
for(var i = 0, n = l.length; i < n; ++i) {
domEvents.addEventListener(l[i], 'click', showId);
}
});