0

While using HTML Textbox in content editor and from Chrome or Mozilla User presses Enter key leading to edit mode of the page. Issue with SharePoint 2010 and SharePoint 2013

0
<script>

// SharePoint input element bug handler
// More bug: http://social.technet.microsoft.com/Forums/sharepoint/en-US/33df42ba-00b3-41a8-8fb9-f8187cfc216d/strange-behavior-in-firefox-input-text-with-enter-opens-page-for-editing?forum=sharepointgeneralprevious
// This fix stops form submit => blocks transfer to edit mode

var disableFormSubmitDueToBug = false;
var bugSubmitHandlerAttached = false;

$('text box id or class').keydown(function(e){
if(e.keyCode == 13 ) { 
  disableFormSubmitDueToBug = true;
  bindBugSubmitHandler();
} else {
  unbindBugSubmitHandler();
}
}).focusout(function(){
unbindBugSubmitHandler();
});

function bindBugSubmitHandler(){
$( "form" ).bind("submit", function( e ) {
if(disableFormSubmitDueToBug) {
e.preventDefault();
console.log('Blocked submit by SP bug handler');
}
bugSubmitHandlerAttached = true;
});
}

function unbindBugSubmitHandler(){
if(bugSubmitHandlerAttached){
$( "form" ).unbind("submit");
bugSubmitHandlerAttached = false;
console.log('SP bug submit handler unbind occurred');
}
}
</script> 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.