This is a migrated thread and some comments may be shown as answers.

Value from a text field shows up in an autocomplete field in Chrome when back button is pressed

1 Answer 99 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Troy
Top achievements
Rank 1
Troy asked on 08 Oct 2013, 01:40 AM
I have a page with 4 autocomplete fields and one text field all in a row. The fields are used to apply filters to a grid. When I enter something in the plain text field, and apply the filters to the grid, everything works fine. The filters are applied and the data in the grid is reduced. When I then click a link in the grid to view the detail page for the record, and then click the back button to get back to the grid, the value that was in the text field is displayed in the first autocomplete box for some reason. 

I save the grid state to localStorage using the dataBound event of the grid:

$('.grid').kendoGrid({
    ...
    dataBound: this.saveGridState
    ...

Where this.saveGridState is: 

var grid = $('.grid').data('kendoGrid');
  var dataSource = grid.dataSource;
  var state = JSON.stringify({
    page: dataSource.page(),
    pageSize: dataSource.pageSize(),
    sort: dataSource.sort(),
    group: dataSource.group(),
    filter: dataSource.filter()
  });
  localStorage.setItem('gridState', state);

I load the state when the document is ready using:
$(document).ready(function(){
    var state = JSON.parse(localStorage.getItem('gridState'));
    var grid = $('.grid').data('kendoGrid');
    if(state && Object.keys(state).length > 0) {
      if(state.filter && state.filter.filters) {
        ctx.showFiltersInInputs(state.filter.filters);
      }
      grid.dataSource.query(state);
    }
    else {
      grid.dataSource.read();
    }
  });

I initially thought that the function I use to put the filters back into their inputs was mistakenly putting the data in the wrong field. However, if i set a breakpoint in chrome before any of the kendo related javascript, I still see the value in the wrong field. It appears the autocomplete is somehow persisting the value in the plain text field when I browse to the detail page and sticking it in the first autocomplete. Seems really weird. Any idea what this could be?

Thanks,

Troy

1 Answer, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 10 Oct 2013, 06:57 AM
Hello Troy,

I was not able to see the AutoCompletes that you are referring to in the code that you posted. Could you please extract a runnable demo showing the issue that you are describing, so it will be easier for us to narrow down the problem?
 

Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
AutoComplete
Asked by
Troy
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Share this question
or