Coder Social home page Coder Social logo

jquery-esn-autobrowse's Introduction

Version 2.0:
* Added sensitivity option
* Added option for doing POST instead of GET
* Added callback for when plugin is done loading content
* Less mandatory options
* Simplified API, better naming
* Removed Ajax fallback when storage didn't fit all items
* Fixed bug with content not loading when page isn't scrollable after the first fetch.

Also added another demo using the Twitter API

Demo and more info at: http://msjolund.github.com/autobrowse/

jquery-esn-autobrowse's People

Contributors

ajwalters avatar lingo avatar msjolund avatar samjoan 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

jquery-esn-autobrowse's Issues

Binds event to window

Hi there!

Thingie binds event to $(window), which means that if one would want to unbind the event so as to change the url or put another listener to scroll, one would have no means to unbind?

e.g.

$(".element").autobrowse()

$(".element").unbind() would not work, and there would be no way to unbind the event.

Will be adding a pull reuqest in a sec

Cannot customize stop

My feed is being called twice when there's not enough data to fill the screen.

What I would like, is that if the API returns less than 30 results, we stop scrolling, since we hit all the records already. However, this is very custom and would not be acceptable for all use cases so I added a stopFunction to the code:

47a48
>  * * stopFunction     a function that will return true if it is necessary to stop autoscrolling
65c66,67
<         postData: null

---
>         postData: null,
>       stopFunction: function () {}
153c155
<                     if (options.itemsReturned(response) == 0 || (options.max != null && currentOffset >= options.max))

---
>                     if (options.itemsReturned(response) == 0 || (options.max != null && currentOffset >= options.max) || options.stopFunction(response) === true)

this is the diff, pretty simple

so when I call the autoscroll I do like

    $('.requests-table-container').autobrowse({
        url: function (offset) {
                 return apiUrl.replace("!offset", offset);
             },
        template: appendRequestsToDom,
        itemsReturned: function (response) {
            return response.length;
        },
        offset: 0,
        loader: '<div class="loader">'+
                '<img src="images/loader.gif" />'+
            '</div>',
        stopFunction: function (response) {
            return response.length < 30
        }
    });

Missing return in scrollCallback() function

Thanks for the autobrowse code, it was helpful in developing my scripts. One thing I thought I'd point out, it was driving me nuts, on a fast connection, I would get repetitive "No more data to load" messages, and multiple json requests when running out of data. I noticed the function would call itself again and again, looping until the _stopPlugin function had completed. Simply added a return statement when the options.itemsReturned(reponse)=0 was true did the trick and eneded the loop.

-------------------------
// Check if these were the last items to fetch from the server, if so, stop listening
                    if (options.itemsReturned(response) == 0 || (options.max != null && options.itemsReturned(response) + currentOffset >= options.max))
                    {
                        _stopPlugin(scrollCallback)
              -->      return;      // break and do not call scrollCallBack() again
                    }
                    loading = false;
                    scrollCallback()
                };
-----------------------

Cannot customize error handling for 404 and 500 [ and ...]

Hi there,

added a onError param that will be called when jqXHR requests deem correct, as per jquery best practices

the full diff, that will enable both stopFunction and onError follows

47a48,49
>  * * stopFunction     a function that will return true if it is necessary to stop autoscrolling
>  * * onError      a function that will be executed on error (HTTP response 500, etc.)
65c67,69
<         postData: null

---
>         postData: null,
>       stopFunction: function () {},
>       onError: function () {}
153c157
<                     if (options.itemsReturned(response) == 0 || (options.max != null && currentOffset >= options.max))

---
>                     if (options.itemsReturned(response) == 0 || (options.max != null && currentOffset >= options.max) || options.stopFunction(response) === true)
158a163
> 
176c181
<                     jQuery.post(options.url(currentOffset), data, ajaxCallback, "json");

---
>                     jQuery.post(options.url(currentOffset), data, ajaxCallback, "json").error(options.onError);
180c185
<                     jQuery.getJSON(options.url(currentOffset), ajaxCallback);

---
>                     jQuery.getJSON(options.url(currentOffset), ajaxCallback).error(options.onError);

If you need it, I can commit only the changes required for this to work not including the stopFunction :)

Cheers!
Pedro

PS: Sorry I dont create a pull request, I cannot get the proxy to work behind my corporate proxy for the life of me

Loading JSON from local file?

Is it possible to load json from a local file and not from a remote server?

I simply copied the file ParisHilton.JSON which loads from the twitter demo's url into a local file and set the url function as such:

url: function (offset)
{
return "ParisHilton.json";
},

But nothing gets loaded from that file. But if I put back the direct link to the twitter JSON feed like in the example content is loaded just fine.

So is it possible for this plugin to work with a local file? I want to create a JSON file and load it locally as I have mentioned before. How would I go to achieve this?

Thanks

Getting data from service

url: function (offset) { return "http://twitter.com/status/user_timeline/ParisHilton.json?count=10&page=OFFSET&callback=?".replace(/OFFSET/, 1+Math.round(offset/10)); }

there is no as such source available for this plugin. kindly provide a good example how can we pull data from a service in asp.net. it will be highly appreciated. Thanks.

How to stop autobrowsing

i tried this, but its making endless new ajax calls on the end anyway:

    complete: function(obj, response, newElements) {
        if (newElements.length == 0) {
            this.stopFunction;
            return false;
        }
        myMasonry.masonry('appended', newElements);
        myMasonry.masonry('reload');
        myMasonry.imagesLoaded(function() {
            myMasonry.masonry('reload');
        });
    }

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.