简体   繁体   English

如何使用rails视图内容(不是图像)自动滑动主页轮播

[英]How to auto-slide the homepage carousel with rails views content (not images)

Is it possible to build a landing page, which slide automatically between 3 or 4 different partial views?是否可以构建一个登陆页面,在 3 或 4 个不同的局部视图之间自动滑动? Every partial will print a different view of the same data model (not an image slideshow per se), something like top 3 of something, top 3 of something else and so on for infinite loop.每个部分都将打印相同数据 model 的不同视图(本身不是图像幻灯片),例如某事物的前 3 名,其他事物的前 3 名,依此类推,以实现无限循环。

I'm looking for a way to slide on 'pages' instead of 'images', may be loading a full view at the beginning with hidden sections to loop on?我正在寻找一种在“页面”而不是“图像”上滑动的方法,可能会在开始时加载一个完整的视图,其中隐藏部分可以循环播放? Or looping on #relative links in the same doc?还是在同一个文档中的#relative 链接上循环?

Another thing I thought, was an automatic paginator like will_paginate or Kaminari but looping called by an ajax, client side javascript cycle.我想到的另一件事是像will_paginateKaminari这样的自动分页器,但循环由 ajax、客户端 javascript 循环调用。 I don't know if it is praticable and how can be done.我不知道这是否可行以及如何做到。

What do you say?你说什么? Any suggestion will be welcome Luca任何建议都将受到欢迎卢卡

As partials are rendered server side you should follow your 'full view' idea.由于部分呈现在服务器端,您应该遵循“全视图”的想法。 That is, render all of the slides/partials (representations of data as you describe but still slides) then use a javascript slider to display each in turn.也就是说,渲染所有幻灯片/部分(您描述的数据表示,但仍然是幻灯片),然后使用 javascript slider 依次显示每个幻灯片。 This falls back for non-javascript users by displaying all slides.通过显示所有幻灯片,这对于非 JavaScript 用户来说是一种回退。

I want to reiterate that you seem to be confused about server side rendering of partials.我想重申一下,您似乎对局部渲染的服务器端渲染感到困惑。 You cannot use a ruby daemon or scheduler to do this as you are sending the page to your user;当您将页面发送给您的用户时,您不能使用 ruby 守护程序或调度程序来执行此操作; once this has happened you have no control over the page (unless you use javascript to poll your server - I don't recommend you do this).一旦发生这种情况,您将无法控制页面(除非您使用 javascript 来轮询您的服务器 - 我不建议您这样做)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM