Fork me on GitHub
#re-frame
<
2017-10-25
>
cmal08:10:53

Hi, I found the following error only in iPhone safari browser, but cannot find where this error is from. Some one can help? I served the file on https://m.beta.joudou.com/wx/doumi/#/doumi and the error message is:

cmal08:10:00

following the steps to trigger the error.

danielneal08:10:24

have you got the full error message, it looks like it's cut off at "No"....

danielneal08:10:35

usually it would be "No handler found for event ...." or something like that

danielneal08:10:01

odd that it's only in in iphone safari though

cmal09:10:56

Sorry for the cut off version. I will look into that.

cmal09:10:27

Sorry for the wrong information. The error message are not related to the steps. But the steps not work because the component-did-mount not called. This is only on iPhone Safari. It is weird.

cmal09:10:42

the re-frame:no is actually because of no on-failure was provided when using http-xhrio.

danielneal09:10:36

component-did-mount is not getting called at all?

cmal09:10:03

yep. But in Chrome it works.

(defn doumi-use-coupon-custom-coupon-input []
  (let [doumi-doumi (rf/subscribe [:doumi-doumi])
        value       (rf/subscribe [:doumi-use-coupon-custom-value])]
    (r/create-class
     {:display-name        "doumi-use-coupon-custom-coupon-input"
      :component-did-mount (fn [e]     ;;  <-- THIS NOT CALLED
                             (.log js/console e)
                             (.log js/console (r/dom-node e))
                             (.focus (r/dom-node e))
                             #_(.focus (.getElementById js/document "doumi-custom-input")))
      :reagent-render
      (fn []
        [:input {:style
                 {:border     "none"
                  :width      (base 160)
                  :height     (base 58)
                  :outline    "none"
                  :font-size  (base 24)
                  :color      (if (and (>= @value 10)
                                       (>= @doumi-doumi @value))
                                "#444" "#f00")
                  :text-align "center"}
                 :id       "doumi-custom-input"
                 :type     "number"
                 :step     "1"
                 :min      10
                 :max      @doumi-doumi
                 :on-input (fn [e]
                             (let [val (-> e .-target .-value)]
                               (when-not (empty? val)
                                 (rf/dispatch [:doumi-coupon-set-custom-value
                                               (js/parseInt val)])))
                             (if (and (>= @value 10)
                                      (>= @doumi-doumi @value))
                               (rf/dispatch [:doumi-use-coupon-custom-valid true])
                               (rf/dispatch [:doumi-use-coupon-custom-valid false])))}])})))

cmal09:10:25

Even I focused on the :input by hand, the log messages are not printed on the Safari console.

cmal09:10:16

(this only happens on iPhone safari, not Mac safari)

danielneal09:10:10

are there still errors in the console. It could be that the errors are happening before component did mount gets called,

cmal09:10:12

Yes, there are errors. But is that possible that the component was mounted but the component-did-mount not called?

danielneal09:10:20

That's unlikely

danielneal09:10:54

Best to fix all the errors first,

danielneal09:10:41

although that said, it looks like https://medium.com/@brunn/autofocus-in-ios-safari-458215514a5f calling .focus in ios safari won't work :s

danielneal09:10:58

even if you get component-did-mount to fire ok

cmal09:10:22

Any solutions? 😢

cmal09:10:47

I cannot open medium 😢

danielneal09:10:21

oh the firewall ?

cmal09:10:35

yep. only medium

cmal09:10:53

I am trying to open the cached version

danielneal09:10:49

the suggestion in the article is that although you can't call '.focus' on an input in ios safari, you can set a focused style for the element (using css) and scroll the element into view using element.scrollintoview. You just can't raise the keyboard because apple doesn't people doing that if the user not explicitly tapped on something

cmal10:10:33

OK. Thank you very much.

cmal10:10:39

That helps a lot.

cmal11:10:54

Hi, does http-xhrio supports application/x-www-form-urlencoded, I only found one example about multipart/form-data, but my server only allows application/x-www-form-urlencoded.

danielneal11:10:05

I think you can put whatever headers you like

cmal11:10:50

multipart/form-data should be added to :body. But last time I asked the cljs-ajax whether I can add application/x-www-form-urlencoded params but get no answer.

lovuikeng12:10:27

not sure if you'd read @cmal "you must include ring.middleware.multipart-params/wrap-multipart-params in your ring handlers as js/FormData always submits as multipart even if you don't use it to submit files" https://github.com/JulianBirch/cljs-ajax

cmal12:10:29

Yes, but what if my server refuse to handler formdata, but only allowed application/x-www-form-urlencoded?

lovuikeng12:10:33

as pointed out clearly in the same docs, no other support is provided unless there is PR

cmal13:10:53

Thanks a lot.😂

joshkh15:10:06

how do i go about passing a static value into the second function of a dynamic subscription? for example, the parent-id value in the following:

(reg-sub
  ::sub-tags
  (fn [[_ parent-id]]
    [parent-id (subscribe [::tags])])
  (fn [[parent-id tags]]
    "Filter tags based on the parent-id val"))

joshkh15:10:50

that fails because parent-id isn't a reaction (which makes sense, it's an argument for the subscription itself)

joshkh15:10:56

in theory a component would subscribe like (subscribe [::sub-tags "someid"])

joshkh15:10:59

problem solved, i was over complicating things 🙂

(reg-sub
  ::sub-tags
  (fn [] (subscribe [::tags]))
  (fn [tags [_ parent-id]]
    "Filter tags based on the parent-id val"))