Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions examples/filtertable-existing-input.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<h1>jQuery.FilterTable Sample With an Existing Input</h1>
<div class="input-filter-container"><label for="input-filter">Filter the table:</label> <input type="search" id="input-filter" size="15" placeholder="search"></div>
<p>This is a sample of the <a href="http://sunnywalker.github.com/jQuery.FilterTable">jQuery.FilterTable plugin</a> which uses an existing element to filter the table instead of creating its own.</p>
<p>You can filter table values on page load adding a <code>filter=...</code> URL parameter.</p>
<h2>Presidents of the United States of America</h2>
<table>
<thead>
Expand Down Expand Up @@ -83,7 +84,23 @@ <h2>Presidents of the United States of America</h2>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="../jquery.filtertable.min.js"></script>
<script>
function GetURLParameter(sParam) {
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam) {
return sParameterName[1];
}
}
}
$(document).ready(function() {
// this is not required to use the plugin
var _arg = GetURLParameter('filter');
if (_arg!==undefined) { // set a value onload if `search=...` URL parameter
$('#input-filter').val(_arg);
}
// --------------------------------------
$('table').filterTable({ // apply filterTable to all tables on this page
filterSelector: '#input-filter' // use the existing input instead of creating a new one
});
Expand Down
5 changes: 4 additions & 1 deletion jquery.filtertable.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Utilizes bindWithDelay() if available. https://github.com/bgrins/bindWithDelay
*
* @version v1.5.2
* @version v1.5.2 (modified)
* @author Sunny Walker, swalker@hawaii.edu
*/
(function($) {
Expand Down Expand Up @@ -126,6 +126,9 @@
if (created_filter) { // add the filter field and quick list container to just before the table if it was created by the plugin
t.before(container);
}
if (filter.val()!=='') { // if value on load
doFiltering(t, filter.val());
}
} // if the functionality should be added
}); // return this.each
}; // $.fn.filterTable
Expand Down
4 changes: 2 additions & 2 deletions jquery.filtertable.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.