简体   繁体   English

为什么这些 `select` 元素没有被渲染?

[英]Why are these `select` elements not being rendered?

I'm working on a project for a client where there needs to be 125 dropdown menus displayed on one page.我正在为客户开展一个项目,该项目需要在一页上显示 125 个下拉菜单。 I of course am not going to manually add all those so I wrote a simple for expression to do it for me.我当然不会手动添加所有这些,所以我写了一个简单for表达式来为我做。 This works for the vast majority of the dropdown menus (which are just select tags), but some do not show up at all.这适用于绝大多数下拉菜单(只是select标签),但有些根本不显示。 And it is the same three each and every time.而且每次都是相同的三个。 Why are these same three never being rendered?为什么这三个永远不会被渲染? When looking in the Elements view in Chrome Dev Tools, it shows the dropdowns as being in the DOM, but they are not shown.在 Chrome Dev Tools 中的 Elements 视图中查看时,它显示下拉列表在 DOM 中,但它们没有显示。 I've looked at this code over and over and I cannot see anything wrong with it and need a second pair of eyes?我一遍又一遍地查看这段代码,但我看不出它有什么问题,需要第二双眼睛吗? What's going on here?这里发生了什么? ( NOTE: db/get-all-advertisers never returns nil ) Here is the code and a picture of what I'm talking about: 注意: db/get-all-advertisers永远不会返回nil )这是我正在谈论的代码和图片:

EDIT: Turns out this is some absolutely bizarre bug with the browsers or graphics or something on all of my Ubuntu machines.编辑:原来这是我所有 Ubuntu 机器上的浏览器或图形或其他东西的一些绝对奇怪的错误。 Was not able to replicate the bug on my friend's Mac.无法在我朋友的 Mac 上复制该错误。 Everything worked fine.一切正常。

(def new-issue-html
  (hiccup/html
   [:html
    [:head
     [:title "Add an Issue"]
     [:meta {:name "viewport" :content "width=device-width, initial-scale=1.0"}]
     [:link {:rel "stylesheet" :href "css/bootstrap.min.css"}]
     [:link {:rel "stylesheet" :href "css/extra.css"}]
     [:script {:src "js/field-verify.js"}]]
    (let [advertisers (db/get-all-advertisers)]
        [:body
         [:div {:class "container-fluid center"}
          [:h1 "Add an Issue"]
          (conj
           [:form {:method "post" :name "newIssueForm" :action "/new-issue"}
            [:div
             [:label {:for "issue-date"} "Issue Time Period (i.e. \"July/August 2020\"): "]]
            [:div
             [:input {:id "issue-date" :name "issue-date" :style "margin-bottom: 10px;"}]]]
           (for [num (range 1 (inc NUM_OF_ADVERTISERS_PER_ISSUE))
                 :let [ad-slot [:div
                                [:label {:style "margin-right: 10px;" :for (str "ad-slot-" num)} (str num ": ")]
                                (conj
                                 [:select {:id (str "ad-slot-" num) :name (str "ad-slot-" num)}]
                                 (for [advertiser advertisers
                                       :let [option [:option {:value (:advertisers/advertiser_id advertiser)}
                                                     (:advertisers/advertiser_name advertiser)]]]
                                   option))]]]
             ad-slot)
           (anti-forgery-field)
           [:div {:style "margin-top: 10px;"}
            (hf/submit-button {:id "submit" :onclick "return checkForm()"} "Create Issue")])]])]))

问题截图

You can wrap the for s in a doall to force realization of the lazy sequence您可以将for包装在doall以强制实现惰性序列

/edit: /编辑:

It is possibly because of a Chromium bug related to GPU hardware acceleration and double monitors.这可能是因为与 GPU 硬件加速和双显示器相关Chromium 错误。 . . Many people experience a "Linux-only: Empty SELECT dropdown".许多人都遇到过“仅限 Linux:空的 SELECT 下拉列表”。

The bug thread states it is related to double monitors.错误线程指出它与双显示器有关。 A solution is to make the right monitor smaller than the left:一个解决方案是让右边的显示器比左边的小:

不同尺寸的显示器

Another (not successful for everyone) solution is according to this answer to disable hardware acceleration:另一个(并非对所有人都成功)解决方案是根据此答案禁用硬件加速:

The summary is that you need to go to 'settings' then 'advanced settings' in Chrome, then uncheck the hardware acceleration box.总而言之,您需要在 Chrome 中依次转到“设置”和“高级设置”,然后取消选中硬件加速框。

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

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