CSS 未正确添加到 JQM 模板中

发布于 2024-11-30 21:21:28 字数 542 浏览 0 评论 0原文

我正在开发一个 JQuery Mobile 项目,最近我更改了一些数据的显示方式以使用模板(我将它们作为 HTML 字符串发送)。问题来自于 CSS 没有正确添加到类中......有时。这种情况在 Chrome 中比在 Firefox 中更常见,所以我的猜测是它与 CSS 有机会添加之前的页面加载有关。

由于该项目的设置使得“页面”是隐藏的 div,并且对于该部分一次显示一个,因此重新加载/刷新通常无法解决问题。我能想到的确保信息正确加载的最佳方法是在数据传递后以某种方式将 CSS 加载到类中。

有关如何设置项目的更多信息。有一个用于基本导航的主页(main.html,然后单击一个链接,它会将您带到 main.html#DataPage)。当您单击链接在页面之间切换时,通常会调用另一个后端程序,该程序实际检索数据,然后以 json 格式将其发送到页面。脚本获取该数据并将其放入模板中,然后将其放入页面上的 div 中。需要获取 CSS 的类位于模板中(如果重要,则位于 s 中)。 IT 桌面有一个一直有效的硬编码模板,它是一个小数据集,最近更改为使用无法正确获取其 CSS 的模板。

任何帮助或建议将不胜感激。

I'm working on a JQuery Mobile project and I've recently changed the way some data was displayed to use Templates (I was sending them as a string of HTML). The problem comes from the CSS not being added correctly to the classes... sometimes. It happens more often in chrome than it does in firefox, so my guess is that it has something to do with the page loading before the CSS has a chance to be added.

Because the project is set up so that the 'pages' are divs that are hidden and shown one at a time for this part, reloading/refreshing normally doesn't fix the problem. The best way I can think of to make sure the information is loaded correctly is to somehow load the CSS to the classes after the data has been passed.

Some more information about how the project is set up. There is a main page that is used for the basic navigation (main.html then you click a link and it takes you to main.html#DataPage). When you click the links to go between pages, there are usually calls to another backend program that actually retrieves the data, then sends it to the page in json format. A script takes that data and puts it into a template then puts it into a div on the page. The classes that need to get the CSS are in the template (in s if it matters). There is a hardcoded template for the IT desk that has always worked, it is the small data set that was recently changed to using templates that doesn't get its CSS properly.

Any help or suggestions would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清旖 2024-12-07 21:21:28

一位同事指出了如何解决这个问题。在模板中添加了另一个类,并且使用了

$('.newClass').listview()

挖掘堆积如山的文档总是很有趣的,并且以某种方式错过了可以解决问题的一个类。

A coworker pointed out how to fix the problem. Added another class to the template and the used

$('.newClass').listview()

Always fun to dig through mountains of documentation and somehow miss the one class that would fix the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文