padolsey-archive / jquery.fn Goto Github PK
View Code? Open in Web Editor NEWA collection of jQuery plugins
Home Page: http://james.padolsey.com
License: The Unlicense
A collection of jQuery plugins
Home Page: http://james.padolsey.com
License: The Unlicense
I've been getting consistently repeated IE6 javascript errors. If you strip the Demo just down to the rows Apple, Orange, Melon and Banana.
Then in IE6 (at least in IETester version of IE6), on the 16th time that I re-sort the Quantity column or the 8th time that I re-sort the Fruit column I get a 'Number Expected' error from the line of code that does the a > b comparison. The issue seems to be these lines:
a = $(a).text();
b = $(b).text();
a
is being over-written by itself, sometimes it seems that this results in the var a
becoming null or a blank string (I'm not sure which).
If you replace the lines with :
var a1 = $(a).text(),
b1 = $(b).text();
And then use a1
and b1
instead of a
and b
, then the errors stop occurring.
Here's the code I have that gives me these errors:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Sort plugin for jQuery</title>
</head>
<body>
<h1>Demo</h1>
<p>Click on the headers (fruit/quantity).</p>
<table>
<thead>
<tr>
<th>Fruit</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<tr>
<td>Apple</td>
<td>4</td>
</tr>
<tr>
<td>Banana</td>
<td>88</td>
</tr>
<tr>
<td>Orange</td>
<td>11</td>
</tr>
<tr>
<td>Melon</td>
<td>21</td>
</tr>
</tbody>
</table>
<button>Click to sort the list below</button>
<ul>
<li>Lamborghini</li>
<li>Farrari</li>
<li>Masarati</li>
<li>Aston Martin</li>
<li>Porche</li>
</ul>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script src="jquery.sortElements.js"></script>
<script>
var th = jQuery('th'),
li = jQuery('li'),
inverse = false;
th.click(function(){
var header = $(this),
index = header.index();
header
.closest('table')
.find('td')
.filter(function(){
return $(this).index() === index;
})
.sortElements(function(a, b){
a = $(a).text();
b = $(b).text();
return (
isNaN(a) || isNaN(b) ?
a > b : +a > +b
) ?
inverse ? -1 : 1 :
inverse ? 1 : -1;
}, function(){
return this.parentNode;
});
inverse = !inverse;
});
$('button').click(function(){
li.sortElements(function(a, b){
return $(a).text() > $(b).text() ? 1 : -1;
});
});
</script>
</body>
</html>
What can I do the preserve namespaces in the XML entities?
If you look at the result of getting https://raw.githubusercontent.com/mckamey/jsonml/master/jsonml.xslt:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
becomes:
Is there a way to inform YQL not to mess with namespaces?
Got an error in jQuery.js
"a.isResolved is not a function"
With 1.4.2a everything is fine.
Works with jQuery 1.4.2 but not 1.7.2
The demo html sorting doesn't work properly when switching between columns. It will sort one ascending and the next descending. It should always sort the column asc first. I've put the jquery below to do this, with the following fixes.
$(function () {
var th = jQuery('th.sort'); // don't assume all th are sortable
th.click(function(){
var header = $(this),
index = header.index(),
inverse = header.hasClass('asc');
header
.closest('table')
.find('td')
.filter(function(){
return $(this).index() === index;
})
.sortElements(function(a, b){
// allow img sorting on alt text
var aImg = $(a).find('img');
var bImg = $(b).find('img');
if (aImg.size() > 0) {
a = aImg.first().attr('alt');
} else {
a = $(a).text();
}
if (bImg.size() > 0) {
b = bImg.first().attr('alt');
} else {
b = $(b).text();
}
return (
isNaN(a) || isNaN(b) ?
a > b : +a > +b
) ?
inverse ? -1 : 1 :
inverse ? 1 : -1;
}, function(){
return this.parentNode;
});
if (!header.hasClass('asc') && !header.hasClass('desc')) {
// remove any other sorting
$('th.asc').removeClass('asc');
$('th.desc').removeClass('desc');
// set asc
header.addClass('asc');
} else {
// swap asc|desc
header.toggleClass('asc').toggleClass('desc');
}
});
});
Thanks,
Ian
hi, recently we want to add your lib to https://cdnjs.com, could you please add a version for current file, or can we regard them as v1.0.0?
thank you very much!
Doesn't work for me.
Error
jquery...ajax.js (line 59)
data.results[0] is undefined
[Break On This Error]
responseText: data.results[0]
Requesting an XML file for example http://p3p.yahoo.com/w3c/p3p.xml will return:
<title/>
/*
This can be fixed be changing the query from 'select * from html where url="{URL}" and xpath="*"'
to 'select * from xml where url="{URL}"'
but it would make it unusable on other occasions. Is it possible to change the query when dataType: "xml"
is requested?
jquery.fn
det
I just dropped in this plugin and the code seems to be running as it should but when it tries to call my success function it crashes on "Uncaught TypeError: Cannot call method 'replace' of undefined". This is caused because the data.results[0] does not exist. Why would this be happening, am I missing something?
Here is the yql script section "jQuery16408109300213400275_1320019527725({"query":{"count":"0","created":"2011-10-31T00:10:05Z","lang":"en-US"},"results":[]});"
Any help would be great. Thanks
Bryan
Hey!
Thanks for this great script!
I'm sorting with:
$("PROD_CAT_SORT", xml).sortElements(function (a, b) { return parseInt($(a).text(), 10) > parseInt($(b).text(), 10) ? 1 : -1; }, function () { return this.parentNode; });
It works like a charm in all browsers but IE where I get a "Type Mismatch" on this line:
// Since the element itself will change position, we have // to have some way of storing its original position in // the DOM. The easiest way is to have a 'flag' node: nextSibling = parentNode.insertBefore( document.createTextNode(''), sortElement.nextSibling );
Any ideas?
Error with jquery.xdomainajax.js when use $.get with the second parameter to send data, example:
var data = $('form').serialize();
$.get('url', data, function(resp) {
//...
});
The petition fail.
Is it possible to send custom headers and how?
We can do that with normal ajax requests like this:
$.ajax({
headers: { 'x-my-custom-header': 'some value' }
});
See http://jsbin.com/iqujo/58. Which parameters do still work? opacity, ok, what else?
Is it on purpose, that the condition for using the YQL-method contains a check for the request type being explicitly GET?
As in jQuery the request type is GET by default, maybe the check could be changed to be positive, if o.type
is either undefined or matches /get/i
.
Thanks for the plugin!
First, thanks for creating this. It's really great. I was wondering if there was a way to ignore values like "--" in a table I'm sorting. Right now the table cells list grades in percentages (99%, 80%, 60%, etc). But for the students that haven't taken the quizzes yet, it displays "--". The sorter uses it as being "higher" than 100%. I want -- to act as if it were a 0.
Right now I have:
$(document).ready(function(){
var table = $('#course_map_table');
$('.sortable_header')
.wrapInner('<span title="Sort this Column"/>')
.each(function(){
var th = $(this), thIndex = th.index(), inverse = false;
th.click(function(){
table.find('td').not('.unsortable').filter(function(){
return $(this).index() === thIndex;
}).sortElements(function(a, b){
return $.text([a]) > $.text([b]) ?
inverse ? -1 : 1
: inverse ? 1 : -1;
}, function(){
// parentNode is the element we want to move
return this.parentNode;
});
inverse = !inverse;
});
});
it appears as if the proximity location is stuck to the upper left of the target div
Here is the problem:
If you have load this plugin in the page, and that's you are using jQuery multiple selectors like $('.classA, .classB, #id1'). Then the matched element get randomly/duplicate sort without calling the sort function, just by using the jQuery selector. And to be more tricky this happens only on IE!!!
I have been trying to debug, and it seems that in jQuery 1.4.2, there is an internal sort function that is call when using multiple selector on IE.
I fix this by renaming the plugin to sortDomElement() and it's ok.
GET https://query.yahooapis.com/v1/public/yql?callback=jQuery191037529634941777235_1566399508261&q=select+*+from+htmlstring+where+url%3D%22http%3A%2F%2Fnews.bbc.co.uk%22+and+xpath%3D%22*%22&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&format=xml&_=1566399508262 net::ERR_NAME_NOT_RESOLVED,
The exemple doesnt work for me !
can i ignore my first column , because It's my index number, I don't want to change this column.
jquery.xdomainajax.js
does not works properly since Yahoo! updated YQL API.
It says html table is no longer supported.
in response.
The cross-domain-modified jquery.ajax
passes {responseText: ""}
to the callback parameter.
Use htmlstring
table instead.
I wrote sample code (version that not working and fixed one),
you can see what happened in live examples on their github pages.
(I tested these samples on FireFox)
the current solution does not sort file size correctly.
Exemple :
a-100 MB
b- 2 kB
c- 50MB
d- 1 G
e- 190 KB
using sort:
d - 1G
a- 100 MB
e- 190 KB
b- 2 KB
c- 50 MB
Any one resolve this issue.
Hello,
What is the usage limits of YQL queries? Can we worry about that?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.