Skip to content

Commit 557286b

Browse files
committed
fix plugin loading, include fnReloadAjax plugin, change Readme, bump version
1 parent c0206dc commit 557286b

File tree

6 files changed

+62
-12
lines changed

6 files changed

+62
-12
lines changed

Readme.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
This is a gem for Rails >= 3.1 applications. It provides all the basic DataTables files, but not (yet) the extras.
2+
3+
# Install and Usage
4+
5+
First, put the gem in your Gemfile (`gem 'jquery-datatables-rails'`) and run `bundle install`
6+
7+
After installing it you can require it in your _application.js_ file with `\\= require jquery.dataTables.min`, or use the images and stylesheets in the _dataTables_ directory: `<%= image_tag 'dataTables/sortBoth.png' %>`
8+
9+
# Plugins
10+
11+
Right now, the only plugin that is available is fnReloadAjax. Check out the [assets directory][assets].
12+
13+
[assets]: https://github.com/rweng/jquery-datatables-rails/tree/master/vendor/assets/javascripts
14+

Readme.textile

Lines changed: 0 additions & 8 deletions
This file was deleted.

jquery-datatables-rails.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
77
s.version = Jquery::Datatables::Rails::VERSION
88
s.authors = ["Robin Wenglewski"]
99
s.email = ["robin@wenglewski.de"]
10-
s.homepage = ""
10+
s.homepage = "https://github.com/rweng/jquery-datatables-rails"
1111
s.summary = %q{jquery datatables for rails}
1212
s.description = %q{}
1313

lib/jquery/datatables/rails/engine.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Configure for Rails 3.1
22
module Jquery
33
module Datatables
4-
if defined?(::Rails) and Rails.version >= "3.1"
5-
module ::Rails
4+
if defined?(::Rails) and ::Rails.version >= "3.1"
5+
module Rails
66
class Engine < ::Rails::Engine
77
end
88
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Jquery
22
module Datatables
33
module Rails
4-
VERSION = "0.0.1"
4+
VERSION = "0.0.2"
55
end
66
end
77
end
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
$.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw )
2+
{
3+
if ( typeof sNewSource != 'undefined' && sNewSource != null )
4+
{
5+
oSettings.sAjaxSource = sNewSource;
6+
}
7+
this.oApi._fnProcessingDisplay( oSettings, true );
8+
var that = this;
9+
var iStart = oSettings._iDisplayStart;
10+
11+
oSettings.fnServerData( oSettings.sAjaxSource, [], function(json) {
12+
/* Clear the old information from the table */
13+
that.oApi._fnClearTable( oSettings );
14+
15+
/* Got the data - add it to the table */
16+
for ( var i=0 ; i<json.aaData.length ; i++ )
17+
{
18+
that.oApi._fnAddData( oSettings, json.aaData[i] );
19+
}
20+
21+
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
22+
that.fnDraw();
23+
24+
if ( typeof bStandingRedraw != 'undefined' && bStandingRedraw === true )
25+
{
26+
oSettings._iDisplayStart = iStart;
27+
that.fnDraw( false );
28+
}
29+
30+
that.oApi._fnProcessingDisplay( oSettings, false );
31+
32+
/* Callback user function - for event handlers etc */
33+
if ( typeof fnCallback == 'function' && fnCallback != null )
34+
{
35+
fnCallback( oSettings );
36+
}
37+
}, oSettings );
38+
}
39+
40+
/* Example call to load a new file */
41+
oTable.fnReloadAjax( 'media/examples_support/json_source2.txt' );
42+
43+
/* Example call to reload from original file */
44+
oTable.fnReloadAjax();

0 commit comments

Comments
 (0)