Question

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

Was it helpful?

Solution

<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> 
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top