We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
这是我用来让评级插件工作的一些代码。全部都是 Ajax,因此我向 RatingHelper 添加了一项 hack,以避免显示“Rate!”按钮,只需将 Submit=>false 添加到选项中即可。
我有一个索引视图,显示了一堆汽车模型,并且显示了总体评分和当前用户评分:
然后我有一些 Jquery 优点来创建星星,然后对单击做出反应
另外,我需要一点 css 片段隐藏 Cake 添加的单选按钮标签。
然后在控制器中,我检查用户之前是否对项目进行了评分,如果没有则保存。我返回一个 json 数组,其中包含总体评级的渲染元素、用户评级(新的或现有的)以及要在 2 秒后消失的 div 中显示的字符串消息。
以下是显示总体评级星级的元素的代码,它可能应该是帮助程序的一部分。
因此,虽然这不是一个非常详细的指令,但您应该能够弄清楚代码在做什么并复制它。我花了大半天的时间才让它工作起来。
Here is some code that I used to get the ratings plugin working. It is all Ajax, so I added one hack to the RatingHelper to avoid showing a "Rate!" button, just add submit=>false to the options.
I have an index view that is showing a bunch of car models and I show an overall rating and the current users rating:
Then I have some Jquery goodness to create the stars and then react on the click
Plus I need a little snippet of css to hide the radio button labels that Cake adds.
Then in the controller, I check if the user has rated the item before and save if not. I return a json array that contains a rendered element of the overall rating, the users rating (new or existing) and a string message to show in a div that disappears after 2 seconds.
Here is the code for the element that shows stars for the overall rating, it probably should be part of the helper.
So while that isn't a super-detailed instruction, you should be able to figure out what the code is doing and replicate it. It took me the better part of a day to get it working.