class Element

Element

Represents an element on the user’s page, with a corresponding jQuery selector which can be used to call jQuery functions on the user’s page.

Shot Framework - Copyright © Jesse Aaron Dunlap <me@jessedunlap.me> Licensed under the MIT License. For full licensing information, please see LICENSE.md. github.com/JesseDunlap/shot/

Attributes

app[RW]

Associated ApplicationInstance

selector[RW]

jQuery Selector

Public Class Methods

from_app_and_selector(app, selector) click to toggle source
# File lib/shot_mvc/element.rb, line 18
def self.from_app_and_selector(app, selector)
        element = Element.new selector
        element.app = app
        element
end
new(selector) click to toggle source
# File lib/shot_mvc/element.rb, line 24
def initialize(selector)
        @selector = selector
        @app = nil
end

Public Instance Methods

html=(html) click to toggle source
# File lib/shot_mvc/element.rb, line 39
def html=(html)
        self.jq 'html', [html]
end
jq(method, parameters = {}) click to toggle source
# File lib/shot_mvc/element.rb, line 29
def jq(method, parameters = {})
        unless app == nil
                @app.emit 'jq', {
                                'selector'    => @selector,
                                'method'      => method,
                                'parameters'  => [parameters]
                }
        end
end
render(template, data = nil) click to toggle source
# File lib/shot_mvc/element.rb, line 47
def render(template, data = nil)
        template = @app.get 'template', template
        template.data = data unless data == nil
        self.html = template.render
end
text=(text) click to toggle source
# File lib/shot_mvc/element.rb, line 43
def text=(text)
        self.jq 'text', [text]
end