artdarek / pusherer

Pusher Service Provider for Laravel 4.
48 stars 13 forks source link

Backbone ,Laravel and pusherer #2

Closed hiddenl00p closed 9 years ago

hiddenl00p commented 10 years ago

Hi,

I am integrating laravel 4 with backbone and using pusherer. In my laravel controller store function I am using public function store() { $task = Task::create(array( 'name' => Input::get('name'), )); Pusherer::trigger('task_channel', 'add_message' , array( 'message' => $task ) ); return $task; }

and on front end(backbone view) I am using following code:

var pusher = new Pusher('xnnnmmmm'); var channel = pusher.subscribe('task_channel'); App.TasksBackpusher = new Backpusher(channel, tasks); App.TasksBackpusher.bind('add', function(model) { alert("create"); });

But its not working. How can i listen to changes in backbone.

Burnett01 commented 10 years ago

I think thats a backbone specific question

hiddenl00p commented 10 years ago

Hi,

for store Pusherer::trigger('channel', 'created' , $tabc->toArray() ); for destroy: Pusherer::trigger('channel', 'destroyed' , $tabc->id );

works fine but for update what should i pass id or all attributes like store. I have tried Pusherer::trigger('channel', 'updated' , $tabc->toArray() ); but it behaves like new addition instead of update. How should i trigger update??