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

2 Answers 2

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> 
2
0

I know this is super old, but the edit page will fire on the keydown event instead of the keyup event. Move your e.preventDefault(); to the keydown for 13, and your good to go. I wouldn't have even found this page if I had been using keydown instead of keyup, as it would have worked as intended.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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