These are chat archives for opal/opal

12th
Mar 2015
George Plymale II
@ylluminarious
Mar 12 2015 16:41

hey everyone, i was recently working on something with opal and i was having problems accessing the body element from the document object: https://developer.mozilla.org/en-US/docs/Web/API/Document/body
i was using this code to try and access body:

$$[:document].body.appendChild(dom_element)

$$[:document] is working fine, but the .body part is coming out as nil. how do i access the body element through $$[:document], then?

Elia Schito
@elia
Mar 12 2015 16:44
@ylluminarious try with $$[:document][:body]
George Plymale II
@ylluminarious
Mar 12 2015 16:46
@elia yeah, i already did, it returns nil :disappointed:
Adam Beynon
@adambeynon
Mar 12 2015 17:55
@ylluminarious has the document loaded? document.body will be null (thus returning nil) until the document has fully loaded
hence jquery needing $(function() { … })
George Plymale II
@ylluminarious
Mar 12 2015 18:03
@adambeynon it looks like it hasn't loaded yet where i'm calling it, so i'll see if i can fix that and then see if the issue persists
Adam Beynon
@adambeynon
Mar 12 2015 18:03
@ylluminarious any reason not to use opal-jquery or opal-browser? (just curious)
George Plymale II
@ylluminarious
Mar 12 2015 18:05
@adambeynon i am using opal-browser
is there a different way to implement what i said in opal-browser?
Adam Beynon
@adambeynon
Mar 12 2015 18:05
@ylluminarious ah ok. I think @meh added a helper for the browser being ready, which works cross browser
document being ready*
George Plymale II
@ylluminarious
Mar 12 2015 18:06
hmm, that's interesting
Adam Beynon
@adambeynon
Mar 12 2015 18:07
found it: $document.ready { puts “document.body exists!” }
George Plymale II
@ylluminarious
Mar 12 2015 18:15
@adambeynon hmm, i got a strange error: https://gist.github.com/ylluminarious/00239c47d1f63706f301
i guess that means that the document isn't ready
Adam Beynon
@adambeynon
Mar 12 2015 18:17
@ylluminarious ummm, not sure on that one. I haven;t done any work on opal-browser, so Im not sure how it works
@meh is the guy to ask - usually on IRC as well
George Plymale II
@ylluminarious
Mar 12 2015 18:18
alright. i'll check on there and see if he can offer any help.
George Plymale II
@ylluminarious
Mar 12 2015 20:57
@adambeynon @elia @meh i think i've fixed that particular issue myself. i tried using $document.body instead of $$[:document].body, and that seems to have solved the problem. thanks, though, for the help