Skip to content

Instantly share code, notes, and snippets.

@rahulsahay19
Created December 21, 2016 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulsahay19/54f76e4c1d8e484d38aa138b8be69279 to your computer and use it in GitHub Desktop.
Save rahulsahay19/54f76e4c1d8e484d38aa138b8be69279 to your computer and use it in GitHub Desktop.
handlers
define("movieApp",["jquery","movieManagement"],function($,movieManagement){
/* event handlers */
function _addMovie(){
movieManagement.add();
}
function _clearMovie(){
movieManagement.clear();
}
function _saveMovie(){
movieManagement.save();
}
function _deleteMovie(clickEvent){
movieManagement.remove(clickEvent);
}
// Its good idea to prefix private methods with _
function _registerEventHandlers() {
$("#new-movie-button").on("click", _addMovie);
$("#delete-all-button").on("click", _clearMovie);
$("#save-button").on("click", _saveMovie);
$("#movie-list").on("click", ".delete-button", _deleteMovie);
}
return{
init:function(){
_registerEventHandlers();
movieManagement.render();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment