Does backbone.stickit support auto-complete?

I have a problem with binding a simple login form to a model. The autocomplete event will not be recognized by stickit, and therefore the view is not synchronized with the model.

html is pretty straight forward:

<form> <input id="username" type="text"/> <input id="password" type="password"/> </form> 

The view will be initialized with an empty model and associated with the render function. Here is an excerpt from the code:

 bindings: { '#username': 'username', '#password': 'password' }, ... initialize: function () { this.model = new Backbone.Model(); } ... render: function() { this.stickit(); } 

If I get the value by calling $('username').val() in the initialize function, I get the correct autocomplete value.

Does anyone know a solution to this problem?

I did not create a problem in the git repository because I am not sure if I am doing something wrong and autocomplete works out of the box.

Thanks in advance!

back

+4
source share
2 answers

Stickit does not currently support browser autocomplete. Here is the GitHub question: https://github.com/NYTimes/backbone.stickit/issues/168

+1
source

There seems to be no standardization on how browsers or plugins magically populate autocomplete input fields; it seems that in most cases change events are not generated, so the model will not be synchronized with the view. Before saving the login model, we do the following:

this.$('input').change();

In principle, violent events of a fire change at any entrance, therefore, change handlers are performed for the fields, after which the model should correspond to the representation.

+1
source

Source: https://habr.com/ru/post/1486792/


All Articles