Reputation: 65
I have a simple coffeescript to process a specific selector (part_ids) ..
alert "Starting blines " + $("[id*=part_id]").length
for bl in $("[id*=part_id]")
do(bl) ->
procBl bl
procBl = (bl) ->
alert "# of children " + bl.children().length
First alert show 2 items are on the page. For loop runs -- however the procBl doesn't print the alert (it quietly exits) It appears that bl that's being iterated and passed to the function is not the correct object and I can't figure out what's it and wrong with this code -
any help is appreciated
Upvotes: 1
Views: 38
Reputation: 193261
bl
passed into procBl
function is not a jQuery instance, but plain DOM element. Wrap it with $()
to use children
method:
procBl = (bl) ->
alert "# of children " + $(bl).children().length
... or use $.fn.each
method to iterate over $("[id*=part_id]")
collection.
Upvotes: 1