On 10/11/06, Chris <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> Originally I had this long post describing what I'm doing and where I'm
> stuck and yadda yadda yadda. I think what it boils down to is that I
> just don't know what the syntax of some of this js means.
>
> I've searched several times in the past for what I consider "advanced"
> js but all I seem to find are people who seem to still be living in the
> late 90s.
>
> Here's a specific example of something I don't quite understand:
>
> (This comes from ajax_tables.js. I cut out some of the code for
> brevity.)
>
> loadFromDataAnchor = function (ev) {
> ignoreEvent(ev);
> var format = this.getAttribute("mochi:dataformat");
> var href = this.href;
> sortableManager.loadFromURL(format, href);
> };
>
> SortableManager.prototype = {
>
> "initialize": function () {
> // just rip all mochi-examples out of the DOM
> ...
> // make a template list
> ...
> // set up the data anchors to do loads
> var anchors = getElementsByTagAndClassName("a", null);
> for (var i = 0; i < anchors.length; i++) {
> var node = anchors[i];
> var format = getAttribute(node, "mochi:dataformat");
> if (format) {
> ---------> node.onclick = loadFromDataAnchor;
> }
> }
> },
> ...
> };
>
> Is 'node.onclick = loadFromDataAnchor' adding an onclick event to the
> current node?
Yes, but you probably ought to be using MochiKit.Signal's connect
function for that instead... the example should be updated at some
point.
> Then going to the definition of loadFromDataAnchor...
>
> loadFromDataAnchor = function (ev) {
>
> What is 'ev' and where does it come from? At this point I assume it
> means "event" but I'm not positive. But even if it does, I'm not sure
> how it's being used.
It does.. the first parameter to event handlers is the event object in
every browser except IE, where it is a global object named event.
-bob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---