Skip to content

Commit

Permalink
proper event attachment for close and create channels
Browse files Browse the repository at this point in the history
  • Loading branch information
kevzettler committed Apr 5, 2012
1 parent bf78300 commit d6da3f0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/assets/javascripts/backbone/views/chatarea.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ class Kandan.Views.ChatArea extends Backbone.View
template: JST['chatarea']
# className: 'channels'

events:
"click .ui-icon-close" : "deleteChannel"
"click .create_channel": "createChannel"
# events:
# "click .close_channel" : "deleteChannel"
# "click .create_channel": "createChannel"

render: ->
$('.header .logo').after(@template({channels: @options.channels}))
$('.close_channel').click(@deleteChannel);
$('.create_channel').click(@createChannel);
for channel in @options.channels.models
view = new Kandan.Views.ChannelPane({channel: channel})
$(@el).append(view.render().el)
$(@el).attr('id', 'channels')
@

createChannel: (event)->
console.log("createChannel called", event);
channelName = prompt("What's the channel name?", "New channel")
channelName = channelName.replace(/^\s+|\s+$/g, '')
if channelName
Expand All @@ -27,6 +30,7 @@ class Kandan.Views.ChatArea extends Backbone.View
console.log "create channel: #{channelName}"

deleteChannel: (event)->
console.log("delete channel called");
channelIndex = $(event.target).parent().prevAll().length
console.log "request for deletion", channelIndex
Kandan.Helpers.Channels.deleteChannelByTabIndex(channelIndex) if channelIndex != 0

0 comments on commit d6da3f0

Please sign in to comment.