tried to make my application more functional by including ajax to my tables. I used this http://asciicasts.com/episodes/240-search-sort-paginate-with-ajax tutorial to create my code and kept very, very close to the instructions.
I'm using IE8 (what could be the cause of the problem since its always the cause of the problem) and Rail 4.
My application.js
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require_tree .
$(function () {
// Sorting and pagination links.
$('#pimps th a, #pimps .pagination a').live('click', function () {
$.getScript(this.href);
return false;
});
// Search form.
$('#pimps_search').submit(function () {
$.get(this.action, $(this).serialize(), null, 'script');
return false;
});
})
index.js.erb
$('#pimps').html('<%= escape_javascript(render(:partial =>"pimps")) %>'));
index.html.erb
<h1>Improvements: Overview</h1>
<%= form_tag pimps_path, :method => 'get', :id => "pimps_search" do %>
<%= hidden_field_tag :direction, params[:direction] %>
<%= hidden_field_tag :sort, params[:sort] %>
<p>
<%= text_field_tag :search, params[:search] %>
<%= submit_tag "Search", :title => nil %>
</p>
<% end %>
<div id="pimps"><%= render 'pimps' %></div>
<div class="row">
<div class="col-md-10"><%= will_paginate @pimps %></div>
<div class="col-md-2"><%= button_to 'New Improvement', new_pimp_path, :method => :get %></div>
</div>
I also ran rails g jquery:install
My layout application.html.erb
<!DOCTYPE html>
<html lang="en">
<head>
<title>Improvement</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<%= yield %>
</body>
</html>
Does anyone know what could be the problem here? If its IE8, is there a way to integrate AJAX nevertheless?
Best regards my friends!