HTML and CSS Reference
In-Depth Information
<script>
var pusher = new Pusher('<?php echo PUSHER_KEY; ?>'),
channel = pusher.subscribe('<?php echo $channel; ?>');
</script>
</body>
</html>
Binding to Events
The app is now subscribed to a channel, but at this point it still needs to listen for the individual events.
Create an Initialization JavaScript File
In an effort to keep the footer clean, create a new file in
assets/scripts/
called
init.js
and initialize it with the
following:
/**
* Initialization script for Realtime Web Apps
*/
(function($) {
})(jQuery);
This file will contain the rest of the app's JavaScript.
■
Wrapping your app scripts in a closure[footnote] prevents conflicts with other libraries that use the dollar sign (
$
)
shortcut, such as prototype and Mootools.
Tip
Load this file in your app by inserting the following bold code into the footer:
<script src="
http://js.pusher.com/1.12/pusher.min.js"></script
>
<script src="
http://code.jquery.com/jquery-1.8.2.min.js"></script
>
<script>
var pusher = new Pusher('<?php echo PUSHER_KEY; ?>'),
channel = pusher.subscribe('<?php echo $channel; ?>');
</script>
<script src="<?php echo APP_URI; ?>assets/scripts/init.js"></script>
</body>
</html>
Search WWH ::
Custom Search