down100009 2016-03-14 07:18
浏览 7
已采纳

如何在单击分页链接时在价格滑块中仅完成后期操作后的从和更改值

Actually I'm doing filtering option with pagination.And in that I use checkbox and price slider for performing filters.

I wrote code for the checkbox option as when pagination links were clicked it must checked which checkboxes were clicked..

And coding is here,

<?php
if(isset($_REQUEST['key'])){
 $key_val = $_REQUEST['key'];
 if(in_array($amn->ht_amenity_id, $key_val)){
                                        ?>
    <label>
    <input class="i-check iCheck-helper" name="{{$keys[$i]}}" type="checkbox" value="{{$amn->ht_amenity_id}}" checked="checked" />{{$amn->ht_amenity_name}}
<?php
    echo "<br/><br/>";
        }
 else{
?>
    <label>
    <input class="i-check iCheck-helper" name="{{$keys[$i]}}" type="checkbox" value="{{$amn->ht_amenity_id}}" />{{$amn->ht_amenity_name}}
<?php
    echo "<br/><br/>";
}}
?>

It works for me..

Here is My code for price slider,

<li>
    <h5 class="booking-filters-title">Price</h5>
    <?php
    if(isset($_REQUEST['from']) && isset($_REQUEST['to'])){
    $from = $_REQUEST['from'];
    $to = $_REQUEST['to'];
    echo $from;exit;
    ?>
        <input type="text" id="price-slider" value="$from;$to">
    <?php
    }
    else{
    ?>
    <input type="text" id="price-slider">
    <?php 
        }
    ?>
</li>

I tried like this way..But it didn't work for me..

When my pagination links were clicks it pass all the values through the URL.And also the results were given as per my filters.

But the price slider does not change after my pagination links were clicked..

And here is my controller code,

$query = "SELECT `h`.*,".$countquery.",".$minquery." FROM `abserve_hotels` as `h`";

        $query1 = DB::select($query.$sqlCond);
        // $perPage = 2;
        $currentPage = Input::get('page', 1) - 1;
        $pagedData = array_slice($query1, $currentPage * $perPage, $perPage);
        $query1 =  new Paginator($pagedData, count($query1), $perPage);
        $query1->setPath('hotelresults');

And in My view I use echo $query1->appends($_REQUEST)->render(); like this to call the pagination

Someone help me.. Thanks

  • 写回答

1条回答 默认 最新

  • dqenv99518 2016-03-19 11:32
    关注

    Checkbox code is same as it.And my code for price slider is here,

    javascript-Ajax

     $(document).ready(function()
        {
                var from_num = <?php echo json_encode($from)?>;
                var to_num = <?php echo json_encode($to)?>;
                var from_default = <?php echo json_encode($from_default)?>;
                var to_default = <?php echo json_encode($to_default)?>;
    
            var sel = "";
            var nme = "";
    
            function somethingChanged(from_num,to_num,sel,nme) {
                // alert(from_num);
                var sel = $('.i-check:checked').map(function(_, el) {
                            return $(el).val();
                    }).get();
                var nme = $('.i-check:checked').map(function() {
                            return $(this).attr("name");
                    }).get();
    
                  $.ajax({
                    // alert();
                    url: 'hotelresults',
                    type: 'POST',
                    data: {
                        from: from_num,
                        to: to_num,
                        key: sel,
                        name: nme,
                        page:page
                    },
                    success: function(data) {
                      $('.hotel_list').html(data);
                    }
                  });
            }
    
            $("#price-slider").ionRangeSlider({
                from:from_num,
                to:to_num,
                min: from_default,
                max: to_default,
                type: 'double',
                prefix: "$",
    
                onChange : function (data) {
    
                    var from_num = data.fromNumber;
                    var to_num =data.toNumber;
                    somethingChanged(from_num,to_num,sel,nme);
                }
            });        
    
            $( ".iCheck-helper" ).on( "click", function(){
                var price=$("#price-slider").val();
    
                var myarr = price.split(";");
                var from_num = myarr[0];
                var to_num = myarr[1];
    
                somethingChanged(from_num,to_num,sel,nme);
    
            });
        }); 
    

    Here I use from_default and to_default from database using queries and I pass it here to set the min and max option.

    Before I using this code the results were shown as per post action.

    i.e.,If pagination links where clicked, the min and max values are also changed in my page by setting the posted min and max value as default price slider minimum and maximum values..

    So for this only I use the from_default & to_default as the price slider minimum and maximum values.

    When I change the slider option it pass the values in post action, but the min and max values are assign to be default values.So it doesn't change.

    Only the from & to values were changed as per my post action.

    Thanks,

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?