CodeIgniter Forums
Pusher not working with codeigniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Pusher not working with codeigniter (/showthread.php?tid=52084)



Pusher not working with codeigniter - El Forum - 05-29-2012

[eluser]Unknown[/eluser]
I have a simple scenario. User submits a comment and an alert should be displayed that there is a new comment.

This is in my view file's header.


Code:
[removed]



var pusher = new Pusher('key');
var channel = pusher.subscribe('comments-2');



channel.bind('new_comment', function(data) {
    alert('An event was triggered with message: ' + data.message);


});

A comment submission is handled by the following method:

Code:
function comment() {




                    $i = $this->session->userdata('id') ;
                    $u = $this->session->userdata('user') ;
                    $ti = $this->chat_model->getTopicID($i);
                    $c = $this->input->post('title') ;


                    $arr = array(

                        'comment' => $c,
                        'topic_id' => $ti,
                        'comment_user' => $u                    

                    );


                    $this->db->insert('comments',$arr) ;

                    $this->pusher->trigger('comments-2', 'new_comment', array(

                        'comment' => $c,
                        'topic_id' => $ti,
                        'comment_user' => $u        

                    ));


                    $data['id'] = $i ;
                    $this->load->view('chat',$data);


        }

Using this library: https://github.com/antonigiske/Pusher-CI

Help please



Pusher not working with codeigniter - El Forum - 05-29-2012

[eluser]sanir[/eluser]
hi,

Please elebrate which error you have seen.


Thanks,
Nasir Ranta