Skip to content

Instantly share code, notes, and snippets.

@teltploek
Created October 28, 2014 07:54
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 teltploek/ce619b6077f04575ec08 to your computer and use it in GitHub Desktop.
Save teltploek/ce619b6077f04575ec08 to your computer and use it in GitHub Desktop.
/*
===================================
Pentia (PT) Namespace
===================================
*/
var PT = PT || {};
/*
===================================
PT.FormInterceptEnter
===================================
*/
PT.FormInterceptEnter = {
/*
===================================
Variables
===================================
*/
Variables: {
textboxes: jQuery('.js-intercept-enter')
},
/*
===================================
Setup
===================================
*/
Setup: function () {
PT.FormInterceptEnter.Variables.textboxes.keypress(function (e) {
var elem = jQuery(this);
var code = (e.keyCode ? e.keyCode : e.which);
if (code === 13 && jQuery('#' + elem.data('button-id')).length > 0) {
e.preventDefault();
jQuery('#' + elem.data('button-id')).trigger('click');
}
});
}
};
/*
===================================
Initialize
===================================
*/
jQuery(document).ready(function () {
if (!jQuery('body').hasClass('pageedit')) {
PT.FormInterceptEnter.Setup();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment