My modal doesn't open when I click the images. What do I need to fix? (ns…
- User
My modal doesn't open when I click the images. What do I need to fix?
(ns jimmystore.pages.photo-page (:require [clojure.string :as str] [jimmystore.image-utils :as image-utils] [re-frame.core :as rf] [reagent.core :as ra]))
(defn photo-card [photo title pic-id]
[:div {:class "col-md-2-5 col-5 m-md-2 m-3"} [:div.card [:div {:class "img-container"} [:img {:src (image-utils/img-blob->img-src photo) :class "card-img-top" :data-toggle "modal" :data-target (str "#" pic-id)}]]] [:div.card-body [:h5.card-title.text-center title pic-id]] ])
(defn remove-extension "Chops off the last period and everything after it in a filename." [filename] (first (str/split filename #"(?=.[^.]+$)")))
(defn photos-element [items img] (let [item-coll (take 16 (:items items))] ; later this can be sorted in different ways, hard limit of 16 [:div {:class "container d-flex flex-wrap align-items-center justify-content-center"} (map-indexed (fn [idx item] (let [pic-id (:id item) ; get id from item img-data (get img pic-id)] ; retrieve data stored under the pic-id key (when-not img-data ; then only fetch if img-data is not already present (rf/dispatch [:retrieve-item-picture pic-id [:retrieve-picture-success pic-id]])) [photo-card img-data (remove-extension (:name item)) pic-id])) item-coll)]))
(defn photo-modal [modal-id photo description sizes] [:div.modal.fade {:id modal-id :tabindex "-1" :role "dialog" :aria-labelledby (str modal-id "-label") :aria-hidden "true"} [:div.modal-dialog.modal-dialog-centered :role "document" [:div.modal-content [:div.modal-header [:h5.modal-title {:id (str modal-id "-label")} "Photo Detail"] [:button.close {:type "button" :data-dismiss "modal" :aria-label "Close"} [:span {:aria-hidden "true"} "×"]]] [:div.modal-body [:div.row [:div.col-md-8 [:img {:src (image-utils/img-blob->img-src photo) :alt "Photo" :class "img-fluid"}]] [:div.col-md-4 [:p description] (for [size sizes] [:button.btn.btn-primary.m-1 {:type "button"} size])] ;; Add your proceed to purchase button here, with relevant onclick handler if needed [:button.btn.btn-success {:type "button"} "Proceed to Purchase"]]] [:div.modal-footer [:button.btn.btn-secondary {:type "button" :data-dismiss "modal"} "Close"]]]]])
(defn page [] (ra/with-let [_ (rf/dispatch [:get-items]) items (rf/subscribe [:items]) img (rf/subscribe [:img]) dbdb (rf/subscribe [:dbdb])] [:div{:class "container"} [:h3 "Select a photo."] [photos-element @items @img] ;; [:p (str @img)] ]))
(def page-info {:page-id :photo :view #'page})
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.