jQuery星级评级插件和Knockoutjs

时间:2014-04-06 17:57:05

标签: html knockout.js

我在使用这个问题时遇到了问题,所以我确定我做错了什么。我想使用这个星级评分系统(http://www.fyneworks.com/jquery/star-rating/)和knockoutjs。所以现在我使用foreach绑定显示一堆业务信息,但我想为每个业务添加星级评级。没有星级评级的东西,我的所有业务都显示得很好,但是当我添加星级评级的东西时,我只能展示一个企业,而其他任何企业都不会出现。这就是我所拥有的,我现在知道它有点讽刺,但我对这些东西不熟悉。

 <div style="float: right; width: 360px; height: 700px; overflow-y: scroll; overflow-x: hidden;" data-bind="foreach: Businesses">
        <a href="#" data-bind="attr:{href: '/home/BusinessDetail?name='+ Name}" style="text-decoration: none;">
            <div>
                <h5 data-bind="text: Name" style="font-size: 14px;"></h5>
                <div data-bind="if: Stars===5">
                    <div id="star1" class="star-rating rater-5 star star-rating-applied star-rating-readonly star-rating-on"></div>
                    <div id="star2" class="star-rating rater-5 star star-rating-applied star-rating-readonly star-rating-on"></div>
                    <div id="star3" class="star-rating rater-5 star star-rating-applied star-rating-readonly star-rating-on"></div>
                    <div id="star4" class="star-rating rater-5 star star-rating-applied star-rating-readonly star-rating-on"></div>
                    <div id="star5" class="star-rating rater-5 star star-rating-applied star-rating-readonly star-rating-on"></div>
                </div>
                <br /><h6 data-bind="text: FullAddress"></h6>
                <br />
                <hr style="margin-top: 1px; margin-bottom: 1px;" />
            </div>
        </a>
    </div>


var viewModel = {
        Businesses: ko.observable(),
        BusinessCategories: ko.observable(),
        SelectedCategoy: ko.observable(),
        LatitudeText: ko.observable(33.4633733188117),
        LongitudeText: ko.observable(-111.926908493042),
        MilesText: ko.observable(10)
    };

所以我需要添加一些东西来显示星星,如果星星== 4 ...星= = 3等等。但这里发生了什么?为什么只有一个企业展示?

0 个答案:

没有答案