Sha256: bf7bfcb9679044d550c9d913cc835cfacd40c2af8a796e089048ef4a331cb1b5

Contents?: true

Size: 655 Bytes

Versions: 3

Compression:

Stored size: 655 Bytes

Contents

module Document
  # Accepts a block that will be called once the document is ready. This uses
  # the underlying $(function() { ... }) mechanism. Note, multiple blocks may
  # be passed to this function and they will be called in order.
  #
  # @example
  #
  #     Document.ready? do
  #       puts "document is now ready"
  #     end
  #
  # @return [Document] returns self 
  def self.ready?
    `$(function() { #{yield}; })` if block_given?
    self
  end

  # Returns an {Element} representing the <head> element of the page.
  #
  # @return {Element} head element
  def self.head
    `return $(document.getElementsByTagName('head')[0]);`
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
opal-0.3.2 gems/rquery/lib/rquery/document.rb
opal-0.3.1 gems/rquery/lib/rquery/document.rb
opal-0.3.0 gems/rquery/lib/rquery/document.rb