Aronaman
3 months ago
300
2
Laravel

display price range in blade file

Posted 3 months ago by Aronaman

in my template main_front.js

var siteSliderRange = function() {
    $( "#slider-range" ).slider({
      range: true,
      min: 10000,
      max: 1000000,
      values: [ 200000, 750000 ],
      slide: function( event, ui ) {
        $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
      }
    });
    $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
      " - $" + $( "#slider-range" ).slider( "values", 1 ) );
    };
    siteSliderRange();

search controller

$minPrice=Organization::min('avg_price');//400
      $maxPrice=Organization::max('avg_price');//2000

Blade.search

 <div class="col-sm-6 col-md-4 col-lg-3 mb-4">
            <div class="mb-4">
              <div id="slider-range" class="border-primary"></div>
              <input type="text"  name="text" id="amount" class="form-control border-0 pl-0 bg-white" disabled="" />
            </div>

          </div>

@push('javascript')
<script>
   var siteSliderRange = function() {
    $( "#slider-range" ).slider({
      range: true,
      min: $minPrice,
      max: $maxPrice,
      values: [ $minPrice, $maxPrice ],
      slide: function( event, ui ) {
        $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
      }
    });
    $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
      " - $" + $( "#slider-range" ).slider( "values", 1 ) );
  };
  siteSliderRange();
</script>
@endpush

i try to update the main_front.js using push method in blade, but is not working

any idea ?

Please sign in or create an account to participate in this conversation.