krawaller / kranium

Brains for Titanium
http://www.kraniumjs.com
Other
103 stars 13 forks source link

.attr is not a function #23

Open dave-worley opened 12 years ago

dave-worley commented 12 years ago

using the following code:

        $(".cat-btn").bind "click", (e) ->
            log $(e.source).attr("id")

results in the following error when the .cat-btn is clicked:

[WARN] Exception in event callback. { line = 59; message = "'undefined' is not a function (evaluating '$(e.source).attr(\"id\")')"; name = TypeError; sourceId = 247376960; }

I'm running the titanium sdk version 2.0 with Kranium v. 0.1.4

dave-worley commented 12 years ago

I also just tried this on the kranium 0.2 branch to the same result.

krawaller commented 12 years ago

From just a quick look, my guess is that it is the log function that is undefined, not attr. Is there really a global function called 'log' in your context? Perhaps you meant to write console.log?

(written by David, not Jacob)

dave-worley commented 12 years ago

Yes, there's a log function in scope.

If you take a look at the error message it explains the statement it's evaluating. The .attr function, in any context we've used it, is undefined.

krawaller commented 12 years ago

Absolutely right. Should have turned on brain before polluting the internet. Sorry! :)