Permalink
Browse files

enbrace dt-list to not care about its api (it eats dt tags, not views)

  • Loading branch information...
1 parent 1ad3a4d commit 14a09791ac95014ea2cc71d1df69ba9a93e75bf4 @dodo dodo committed Feb 29, 2012
Showing with 23 additions and 13 deletions.
  1. +17 −2 src/templates/util.coffee
  2. +4 −3 src/views/base.coffee
  3. +2 −8 src/views/channel/postsbase.coffee
View
19 src/templates/util.coffee
@@ -1,8 +1,23 @@
{ List:dtList, jqueryify } = require 'dt-list'
+##
+# dt-list extended with event listener bind method
+# and with the right list callback.
+#
+# call it this way to get the tag (and not the view) into the list:
+#
+# list.push (done) ->
+# view.domready(done)
+#
+# the view should be ready
+# and the template should contain a ready function call (the one down there)
+#
class exports.List extends dtList
constructor: (rootel) ->
- super jqueryify rootel
+ listcallback = jqueryify rootel
+ super (pos, tag) ->
+ this[pos.idx] = tag if tag?
+ listcallback.call this, pos
bind: (emitter, ns = "") ->
ns += ":" if ns?.length?
@@ -31,5 +46,5 @@ exports.load_indicate = (tag) ->
exports.ready = (tag, view) ->
tag.ready ->
- view.trigger 'dom:ready'
+ view.trigger 'dom:ready', tag
View
7 src/views/base.coffee
@@ -7,10 +7,11 @@ class exports.BaseView extends Backbone.View
initialize: ({@parent} = {}) ->
@rendered = no
@domisready = no
- @bind 'dom:ready', =>
+ @bind 'dom:ready', (tag) =>
+ @_tag = tag
@domisready = yes
if @_waitingfordom?
- cb() for cb in @_waitingfordom
+ cb(tag) for cb in @_waitingfordom
delete @_waitingfordom
render: (callback) ->
@@ -42,7 +43,7 @@ class exports.BaseView extends Backbone.View
domready: (callback) =>
return this unless callback?
if @domisready
- callback()
+ callback(@_tag)
else
@_waitingfordom ?= []
@_waitingfordom.push callback
View
10 src/views/channel/postsbase.coffee
@@ -15,15 +15,9 @@ class exports.PostsBaseView extends BaseView
parent:this
return if view.rendering
i = @indexOf(view.model)
-# console.error "============================", i
@ready =>
- @trigger("view:#{@ns}:insert", i, (done) ->
-# console.error "insert", i, view.cid
+ @trigger "view:#{@ns}:insert", i, (done) ->
view.ready ->
- view.domready ->
-# console.error "domeready => ", i, view.el
- view.__defineGetter__('_jquery',->view.el) # FIXME wtfuck?
- done()
- )
+ view.domready(done)
view.render()

0 comments on commit 14a0979

Please sign in to comment.