如何在不影响原始代码的情况下复制此javascript函数

时间:2013-10-31 17:39:22

标签: javascript function slider duplicates

我正在尝试复制此代码而不影响原始代码。

问题: 点击出租时,价格范围滑块变为0-1000 但是当我点击租用时,价格范围滑块变为0m-5m

如何复制此代码并将租借价格范围滑块更改为0-1000? 试图复制原始代码并将租值改为租用,而不是工作。 我在互联网上搜索了复制功能,但这让我很难理解。

Javascript代码:

this.createPriceSlider = function( status ) {
            this.priceSlider.rangeSlider({
                minPriceInput       : 'input#price-from',
                maxPriceInput       : 'input#price-to',
                minPriceDisplayElem : '.min-price-display',
                maxPriceDisplayElem : '.max-price-display',
                currencySymbol      : localizations.currencySymbol,
                range               : true,
                min                 :  status == 'for-rent' ? parseInt( listingSearchVars.priceSliderRentalMin ) : parseInt( listingSearchVars.priceSliderMin ),
                max                 : status == 'for-rent' ? parseInt( listingSearchVars.priceSliderRentalMax ) : parseInt( listingSearchVars.priceSliderMax ),
                values              : 'auto',
                step                : status == 'for-rent' ? parseInt( listingSearchVars.priceSliderRentalStep ) : parseInt( listingSearchVars.priceSliderStep )
            });
        };

        this.restartPriceSlider = function( status ) {
            if ( status !== this.currentListingStatus ) {
                this.currentListingStatus = status;
                this.priceSlider.slider( 'destroy' );

                var minVal = status == 'for-rent' ? parseInt( listingSearchVars.priceSliderRentalMin ) : parseInt( listingSearchVars.priceSliderMin ),
                    maxVal = status == 'for-rent' ? parseInt( listingSearchVars.priceSliderRentalMax ) : parseInt( listingSearchVars.priceSliderMax );

                $( '#price-from' ).val( minVal );
                $( '#price-to' ).val( maxVal );
                this.createPriceSlider( status );
            }
        };

0 个答案:

没有答案