I am attempting to update the value of a @jashkenas/inputs text form using a value derived from a click event in a Leaflet map. The idea here is that a user could either provide the coordinates manually or from clicking on a map.
I am able to get the value I need from the click event, but I am having trouble passing it into the text form. The text form value is apparently a constant. As such it appear I cannot just assign the value from the click event to the variable containing the initial text form value. I’ve included a basic example of what I’ve been trying to. Does anyone have any suggestions for how I can pass the value from a click event into a @jashkenas/inputs text form?
(I think I learned this trick from the Linked Inputs example.)
The “assigning to a constant” error occurs because Observable cells are in strict mode, and inside the cell newCoordinates hasn’t been defined yet. You don’t actually need a new view cell for what you’re trying to do, so I just placed the code defining the event handler directly inside the map cell.
There’s also a fancier technique in Synchronized Views that I’ve also used from time-to-time.
This is great. There are a few concepts I think I need to dig into a bit more, but this approach on the whole makes sense. Thanks for the suggestions and explanation!