A better place to ask then twitter :P

3 views
Skip to first unread message

JoeGaudet

unread,
Aug 24, 2011, 2:00:01 PM8/24/11
to lebowskifw
Hey Mike,

So my issue is this, I have a custom list item that has a TemplateView
in it (I've got them somewhat work, we can talk more about it tomorrow
on skype ?) But within that template view there are embedded views
such as {{view SC.ButtonView }}

I can't give them specific ids, but they do have classes
(.destroy_button, .edit_button).

I can select them as dom elements but I can't seem to wrap them up as
CustomViews, from the look of it things like app[<path>,
<expectedType>] seem to do what I want (when provided an id and a
proxy class).

Maybe I am missing something fundamental here that you could clear up
for me ?

.joe

Some classes I've been working with

module SC
module Views
class TemplateView < Lebowski::Foundation::Views::View
representing_sc_class 'SC.TemplateView'
end
end
end

module Matygo
module Views
class BasicListView < SC::Views::TemplateView
representing_sc_class 'Darkhorse.DrillListItemView'

def label
core_query("label")[0]
end

def delete_button
core_query(".destroy-button")[0] // this is the one I'd
like to be able to coerce into a proxy object for an SC.ButtonView
end
end
end
end

MikeC

unread,
Aug 25, 2011, 2:11:22 PM8/25/11
to lebowskifw
Hey Joe,

The core query component only returns a CoreQuery object consisting of
proxied DOM elements that match the given CSS selector. Currently
there is no logic to change from a DOM element into a proxy. However,
the template view does expose the child_views method in which you can
access the button. You simply need to do the following:

button = self.child_views.find_first('SC.ButtonView')

or

button = self.child_views.find_first(ButtonView)

Both work the same way in which it goes through an array to find the
first element that matches the object type.

In general, Lebowski will need to be updated to properly support
template views. The template view and SC.View both have common
functionality, but the template view directly inherits from the
SC.CoreView, not the SC.View. As for accessing child views within a
template view, using the DOM class is suitable, although it would've
been nice if you could also supply an optional localID property to
each child view to make it easier to access them via a simple property
path :).

-Mike
Reply all
Reply to author
Forward
0 new messages