My script is a simple search machine, where I handle queries, suggestions and results. While typing, the script rebuilds a list of suggestions on keyup events.
I've got three routes: ""
, "search/:query"
and "answerQuestion/:id/:step"
. When a suggestion is clicked, the script goes to the route "search/:query"
. So this is the part of code:
AnswerMachine.Views.Suggestion = Backbone.View.extend({
tagName: 'div',
className: 'suggestion-item alert alert-info',
events: {
'click': 'setQuery',
},
setQuery: function() {
//Сохраняем навигацию
Backbone.history.navigate("search/" + this.model.get('title'));
return this;
},
render: function() {
this.$el.attr('id', this.model.get('id') + '_suggestion');
//Записываем текст внутрь
this.$el.html(this.model.get('title'));
//Возвращаем наш объект
return this;
}
});
But when I click on the suggestion, for example: Что тут происходит?, it redirects me to the url: /#search/'B>%20BCB%20?@>8AE>48B?
. So, what's the problem? Doesn't Backbone.js know cyrillic symbols?
I tried escape method, but when I tried encodeURI() function and decodeURI() it start works in all browsers!