1rosehip / jplist

jPList jQuery Data Grid Controls is a flexible jQuery plugin for sorting, pagination and filtering of any HTML structure (DIVs, UL/LI, tables, etc).
http://jplist.com
Other
438 stars 176 forks source link

Why change ui-slider max value from data? #152

Closed dark46 closed 8 years ago

dark46 commented 8 years ago

Hi! Example: http://output.jsbin.com/oyires/10/

My example:

        , dataSource: {
            type: 'server'
            , server: {
                ajax: {
                    url: 'ajax/json.php'
                    , dataType: 'json'
                    , type: 'POST'
                }
            }
            , render: function (dataItem, statuses) {
                $list.html(template(dataItem.content));
                console.log(dataItem.maxvalue); // dynamic from json receive

                var maxvalue = 5;
                $( '#slider' ).slider("option", "max", maxvalue);  // NOT WORK !!!
            }

I get maxvalue from json response, example:

{"count":2,"maxvalue":5000,"data":[{"blablabla1"},{"blablabla2"}]}

In jplist.core.js add maxvalue:

(function() {
    jQuery.fn.jplist.domain.server.models.DataItemModel = function(a, d, b) {
        this.content = "";
        this.dataType = d;
        this.count = 0;
        this.maxvalue = 0;
        this.responseText = b;
        this.dataType || (this.dataType = "html");
        switch (this.dataType) {
            case "html":
                d = jQuery(a);
                0 < d.length && (this.content = d.html(), this.count = Number(d.attr("data-count")) || 0);
                break;
            case "json":
                this.content = a.data;
                this.count = a.count;
                this.maxvalue = a.maxvalue;
                break;
            case "xml":
                d = jQuery(a).find("root"), this.count = Number(d.attr("count")) || 0, this.content = 0 < this.count ? a : ""
        }
    }
})();

Not work: $( '#slider' ).slider("option", "max", maxvalue);

Why change ui-slider max value from data? Maybe i can using "redrawCallback" and why?

1rosehip commented 8 years ago

jQuery UI slider control is added to jPList php / mysql version: https://github.com/no81no/jplist-php-mysql/blob/master/5-range-slider.html https://github.com/no81no/jplist-php-mysql/blob/master/server/controls/range-slider.php