web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Luke Sartain Dynamics / ClientGlobalContext.js.aspx...

ClientGlobalContext.js.aspx destroys backspace functionality in HTML text fields

Luke Sartain Profile Picture Luke Sartain 1,266

Sounds bonkers but it’s true.  Whilst making some amendments to a custom product picker (HTML web resource) I added a reference to ClientGlobalContext.js.aspx to avoid relying on getting the context from the parent window, which I had some issues with when using turbo forms in Outlook Client.  Shortly after publishing these changes I started to receive reports that the backspace in a HTML input field had stopped deleting text.  Somewhat baffled I headed to Google and stumbled across this post on the community forum stating the problem to be with the aforementioned script.  I must admit that I didn’t believe that that could be the cause of the issue but removed the reference to the script anyway.  Remarkably the backspace started to work again.

As I needed both the script and the backspace working I ended up writing a custom function using jQuery to replicate the backspace functionality.

function keyDown(event) {
            if (event.keyCode === 8) {   //backspace
                var searchValue = $("#search-criteria").val();
                if (searchValue.length > 0) $("#search-criteria").val(searchValue.slice(0, -1));                  

            }
        }

I then added the keyDown function to the input field.

<input type="search" placeholder="Search for product id or name" id="search-criteria" onkeypress="keyPress(event)" autofocus />

I think we can definitely file that one away in the Dynamics idiosyncrasies section.


This was originally posted here.

Comments

*This post is locked for comments