Closed al3x closed 9 years ago
I'm not able to reproduce the issue myself. For example, something like this works fine:
(defn friend-source [text]
(filter
#(-> % (.toLowerCase %) (.indexOf text) (> -1))
["Alice" "Alan" "Bob" "Beth" "Jim" "Jane" "Kim" "Rob" "Zoe"]))
(defn home-page []
(let [doc (atom {})]
(fn []
[:div [:h2 "numeric test"]
[:p "selected value is: " (str @doc)]
[bind-fields
[:div {:field :typeahead
:id :ta
:input-placeholder "pick a friend"
:data-source friend-source
:input-class "form-control"
:list-class "typeahead-list"
:item-class "typeahead-item"
:highlight-class "highlighted"}]
doc]
[:button
{:on-click #(reset! doc {})}
"submit"]])))
The typeahead sets a value in the atom and then the submit button clears it. I'm not seeing any errors in the log. Could you provide a sampler project exhibiting the issue by any chance?
That's strange, I'm seeing the same error when using your example code. Here's what I'm doing:
Also, is it a requirement that the "doc" atom be reset after every form submission? That isn't documented, IIRC.
Ah ok yeah I can see that with hitting enter, I was using the mouse before. As for resetting the doc, that's not required by the library. I was just resetting it to see if that would cause the problem. In practice, you probably would want to reset it on successful submission to clear the form though.
I'll take a look at fixing the enter issue though.
Ok just pushed out 0.5.9
to Clojars with the fix, let me know if everything looks good on your end.
Unfortunately, I'm seeing the same behavior with 0.5.9
.
Actually, my apologies, this does seem to be resolved for me. My CLJS build hadn't updated to reflect the latest version of the dep. Thanks very much for the fix! :tada:
yeah I get burned by the cljsbuild stuff all the time :)
I'm using the typeahead input in a project. It renders fine, and I can successfully use it to populate the input field and submit my form once. However, that form remains on the page (it's a single page app), and on any subsequent uses I get the following error:
The issue seems to be in the
choose-selected
function. I'm not sure how it's getting out of bounds, but the issue is replicable even using the sample data source provided in the README.