jeudi 1 février 2018

Browser back on ajax single page app

I have an script here that loads the data in the div I want to implement browser back button, here which is similar to history.pushState() I am unable to figure out how to achieve that here, P.S its a single page application.And using the Laravel framework in the backend.

$(function() {
  $('#results').hide();

  $("#SearchItem").autocomplete({
    source: ""
  });

  $("a:contains('Specifications')").click(function(event) {
    event.preventDefault(); //to stop refresh/redirecting
    $("#results").load("specifications.blade.php");
  });

  $("#SearchItem").keydown(function(e) {
    if (e.keyCode == 13) {
      $result = [];
      $('#results').show();
      $value = $('#SearchItem').val();
      $.ajax({
        type: 'get',
        url: "",
        data: {
          'SearchItem': $value
        },
        success: function(data) {
          $('#results').html(data);
        }
      });
    }
  })
});



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire