Giter Club home page Giter Club logo

jquery.fn's People

Contributors

mrchief avatar padolsey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery.fn's Issues

Improving the demo.html

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.

  1. I've added a $(function () {}); around the jquery - it fails when moving it to a separate script otherwise
  2. I've added the use of classes to store the sort order (requires adding the sort class to the html)
  3. I've added the ability to sort on img elements (you might want to ignore this)
$(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

IE type mismatch

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?

YQL query: Explicit setting for default data (GET) required

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!

data.results[0] is undefined

Doesn't work for me.

Error
jquery...ajax.js (line 59)

data.results[0] is undefined
[Break On This Error]

responseText: data.results[0]

[cross-domain-ajax] Not works since YQL API's update

Summary

jquery.xdomainajax.js does not works properly since Yahoo! updated YQL API.

It says html table is no longer supported. in response.

Detail

The cross-domain-modified jquery.ajax passes {responseText: ""} to the callback parameter.

Workaround

Use htmlstring table instead.

Samples

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)

Is there a way to ignore if a table cell has some default value like "--"?

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;
        });
      });

Error $.get with data

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.

Requesting XML Data in Cross Domain AJAX

Requesting an XML file for example http://p3p.yahoo.com/w3c/p3p.xml will return:




<title/>


/*




While the expected value would be:



/*


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?

sort number and size

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.

Error with jQuery 1.6.4

Got an error in jQuery.js

"a.isResolved is not a function"

With 1.4.2a everything is fine.

Results always come back empty?

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

custom headers

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' }
});

usage limits

Hello,

What is the usage limits of YQL queries? Can we worry about that?

IE6 javascript error in sortElements demo.html

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>

Side effect on IE when using multiples selectors

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.