shanselman/ASP.NET-MVC-and-DbGeography — pull request #2 by Encosia (2012-09-05 02:54:05+00:00)
Title: Update with JavaScript like the kids write these days.

Since you mentioned me in your post, I figured you might want me to take a pass at your JavaScript. So, here's a pull request. Highlights:

- No global impact. Everything is isolated within a self-executing anonymous function and wires itself up unobtrusively, so no external access to the script is necessary. Especially important if this were to be packaged up for reuse.
- Progressive enhancement. For users without JavaScript (i.e. NoScript or blocking third party scripts), the form won't appear to be broken. The map is added dynamically after the page loads and event handlers are wired up after that. All the script needs is an input field with the CSS class it's expecting to find. This also has the nice side-effect of making that troublesome `textboxid` handling no longer necessary.
- Support for multiple DBGeography view/edit templates on the same page. Any number of properties can share this script on the same page now, with map events correctly isolated from each other.
- Support for users editing the input's value directly. The map updates its marker when the input's onchange fires.
- The DisplayTemplate is no longer editable. Both the map's click event and editing the input itself are not available now when viewing a `DisplayFor`.