Having trouble making Knockout and jCarouselLite to work

若如初见. 提交于 2020-01-06 23:47:33

问题


I have this knockoutjs code that loads images:

self.getStudents = function (country) {
    $.getJSON("/home/getStudents?country=" + country, function (result) {
        if (result.data.length > 0) {
            self.properties.removeAll();
            ko.utils.arrayMap(result.data, function (s) {
                self.properties.push({
                    id: property.Item.Id,
                    address: s.address,
                    city: s.city,
                    state: s.state,
                    country: s.country,
                    image: s.image
                });
            });

            //alert(self.properties().length);

            jQuery(".feature-slider").jCarouselLite({
                btnNext: ".slider-btn.next",
                btnPrev: ".slider-btn.prev",
                mouseWheel: true,
                visible: 8,
            });

            var c_window = jQuery(this).width();
            if (c_window <= 767) {
                jQuery(".house-row").jCarouselLite({
                    btnNext: "#item-next",
                    btnPrev: "#item-prev",
                    visible: 4,
                    speed: 1450
                });
            } else {
                jQuery(".house-row").jCarouselLite({
                    btnNext: "#item-next",
                    btnPrev: "#item-prev",
                    visible: 4,
                    mouseWheel: true,
                    auto: 2000,
                    speed: 6000,
                    hoverPause: true
                });
            }
        }
    });
};

and the HTML that loads it inside the div that jCarouselLite will use:

<div class="house-row">
    <div class="house-row-nav"><a href="javascript:void(0)" id="item-prev"></a></div>
    <div class="house-row-nav"><a href="javascript:void(0)" id="item-next"></a></div>


    <ul>
        <!-- ko foreach: properties -->
        <li>
            <div class="house-row-box nopadding-left nopadding-right">
                <div class="image-wrapper">
                    <img data-bind="attr: { src: image }" alt="image">
                    <i class="icon-bg arrow-bg"><img src="~/Areas/Consumer/Assets/images/arrow-bg.png"></i>+
                    <i class="icon-bg arrow-bg-hover"><img src="~/Areas/Consumer/Assets/images/arrow-bg-hover.png"></i>
                </div>
                <div class="detais-area">

                    <h6 class="box-title"><span data-bind="text: address"></span></h6>
                    <h6><span data-bind="text: country"> </h6>
                    <hr>
                    <div class="pull-left"><div class="bed-count"><i class="icon icon-bed"></i>3</div></div>
                    <div class="pull-right price-box"><h4>约12, 095万元</h4></div>
                    <div class="clearfix"></div>
                </div>
            </div>
        </li>
        <!-- /ko -->
    </ul>
</div>

But the carousel won't work. It displays the image in a top-down manner and doesn't move. When I use static images, everything works properly.

Maybe someone has encountered this and is able to help me? It will really be appreciated. Thanks.

来源:https://stackoverflow.com/questions/31446622/having-trouble-making-knockout-and-jcarousellite-to-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!