These are chat archives for reactioncommerce/reaction

22nd
Feb 2016
Aesop7
@Aesop7
Feb 22 2016 01:15
Hey does reaction use the Meteor email package? Or something else?
Lukas Sägesser
@ScyDev
Feb 22 2016 07:48

@aaronjudd Jquery is not missing. Jquery not being loaded is just a symptom, not the actual problem.
Please read again:

I was relying on Template.productDetail.onCreated() to inject some content. With the code from master branch this worked fine. With the latest code from development, it seems that jQuery is not initialized ($ is not a function) and neither can I find any DOM elements, which I can see in the browser DOM view.

If I simply wrap my code with Meteor.setTimeout(function() { ... ], 100); then it works. This can't be right? The DOM should be rendered and all libraries initialized when this event fires.

Was there any change in RC to cause this behaviour?

newsiberian
@newsiberian
Feb 22 2016 07:56
Could it be so, that Meteor.isClient was missed somewhere?
Kavish Patel
@thekavish
Feb 22 2016 10:56
Hello, can anyone help me with deploying reactioncommerce application using meteor-up
Mike Murray
@mikemurray
Feb 22 2016 13:18
@ScyDev all jQuery stuff needs to go in the onRendered function. OnCreated is equivalent to a constructor, where you set up the data your component will need to render properly
Lukas Sägesser
@ScyDev
Feb 22 2016 14:14

@mikemurray I know :) And thats what I did. I have the same problematic behaviour with onRendered and onCreated. And with development from about 3 weeks ago, it worked perfectly.
Can you try this package https://github.com/ScyDev/reaction/blob/development/packages/reaction-p2p-marketplace-locations/client/templates/products/productDetail/productDetail.js#L5 on latest development?

If you out-comment the Meteor.setTimeout() command and just directly run the contained codeblock in the onRendered callback, does it work?

rkhunter
@rkhunter
Feb 22 2016 16:06
Hey guys, a quick question
Is Paypal okay behind reverse proxy?
Spencer Norman
@spencern
Feb 22 2016 16:28
@ScyDev - we had some problems getting some of our jQuery plugins to run after switching over to flow router and ours were becaues some of our jQuery calls were nested inside of blaze {{with}} or {{each}} blocks. We were able to fix our issues by creating a sub-template for all of our template code within those blocks and then attaching the jQuery calls to onRendered calls within the new templates
Lukas Sägesser
@ScyDev
Feb 22 2016 16:59
@mikemurray @spencern This problem is not jQuery specific. It also happens with var els = document.querySelectorAll('.el');. jQuery not being initialized is just an example. The problem is that onRendered is fired before the DOM (and libraries) are really ready.
Spencer Norman
@spencern
Feb 22 2016 16:59
yeah, that’s what we found too
Lukas Sägesser
@ScyDev
Feb 22 2016 16:59
Hooray :)
Spencer Norman
@spencern
Feb 22 2016 17:00
I didn’t look through through your templates, but our issue was that the template was firing the onRendered callback after the base template was rendered, but before any data was available
I think this is partly/entirely because we aren’t waiting on subscriptions on the router any more
Lukas Sägesser
@ScyDev
Feb 22 2016 17:01
Surely this is a major bug, no? We should be able to rely on DOM and libraries being completely loaded and initialized when onRendered is fired?
Like it was in 0.11 ?
Spencer Norman
@spencern
Feb 22 2016 17:02
I looked around quite a bit, and it seems like this is the way Meteor is designed
not sure if you have any blocks in your template that depend on subscriptions being loaded or not (such as with or each)
but we found that breaking those out into subtemplates, allowed us to depend on onRendered as expected
e.g.
<template>
  <div id=“main”>
    <div id=“secondary”>
      {{each post}}
        <div id=“ternary”>
      {{/each}}
    </div>
</div>
For us, onRendered attached to this template would always fire before #ternary was loaded
We had to break it out so that we had
{{each post}}
  {{> post}}
{{/each}}
and then attach our onRendered methods to that template.
Spencer Norman
@spencern
Feb 22 2016 17:07
where is the productDetail template?
Lukas Sägesser
@ScyDev
Feb 22 2016 17:08
that is the productDetail from core.
Spencer Norman
@spencern
Feb 22 2016 17:08
ah
Lukas Sägesser
@ScyDev
Feb 22 2016 17:09
An event like onRendered can't only be useful sometimes if you have the "correct" template structure. It should works always, and always in the same way. Wouldn't you agree?
Spencer Norman
@spencern
Feb 22 2016 17:10
I agree in principal, but then it’s potentially waiting on subscriptions and child-template subscriptions before it’s ready, so I think it’s more complicated than I originally thought
I think this is what’s blocking the onRendered()
and again I’m not sure if this is a design decision or a side effect, but we found that {{with}} blocks in our packages were making it so that everything inside of them wasn’t ready when onRendered fired
Lukas Sägesser
@ScyDev
Feb 22 2016 17:18

Hmm... I hope @aaronjudd can tell us if it is by design. Hopefully not! :(
Since I'm just trying to act on an event of a core template, and not doing anything with {{with} or {{each}}, it seems like onRendered is broken on a core template, out of the box.

I'll stop ranting now. Thanks for your help! :)

I think in that case, if it’s waiting on subscriptions and child-template subscriptions before it’s ready, that's exactly what it should do. After everything it contains is ready, only then should onRendered be fired.
Aaron Judd
@aaronjudd
Feb 22 2016 17:25
so, yes.. http://guide.meteor.com/data-loading.html#organizing-subscriptions it needs to wait on the subscription in the onCreated. A with will just completely fail to load the template if it’s checking null/undefined data (even if there is an else)
Aaron Judd
@aaronjudd
Feb 22 2016 17:32
I’d suggest trying to wait for the subscription in a this.autorun statement, not sure if onRendered is the best place either, might be better in onCreated (onRendered will only ever run once)
would stay away from a timeout like that (but guess you’re testing), but you might also want to look at Meteor.defer()
Lukas Sägesser
@ScyDev
Feb 22 2016 19:45
@aaronjudd Yes, that timeout was just born out of desperation and I'd love to see it gone. I didn't understand much of what you just said, but will try to make sense of how it applies to my situation :)
Lukas Sägesser
@ScyDev
Feb 22 2016 20:18
@zenweasel I just made a successful Braintree sandbox payment, Thank you!
Spencer Norman
@spencern
Feb 22 2016 20:29
@mikemurray - question about the cart / checkout flow. Currently when a user is on the checkout page, there’s no list of what is in their cart and prices per item. Are there plans for listing items and prices on the checkout flow?
Spencer Norman
@spencern
Feb 22 2016 21:28
What is the ETA on new theming docs? Specifically curious about best practices to rewrite the majority of structural HTML / layout and potentially even changing over to using Foundation/Sass instead of Bootstrap/less
Owen Hoskins
@owenhoskins
Feb 22 2016 21:37
Hey all -- I am just getting my head around the FlowRouter implementation. Is there a procedure for declaring a route without permissions? I see how permissions are set in the registry, but my custom routes are denying access to anonymous users.
David Spencer
@pomaking
Feb 22 2016 22:11
@owenhoskins Are you using the "audience" field, such as in the reaction-checkout package?
Brent Hoover
@zenweasel
Feb 22 2016 22:37
@rkhunter re: Paypal. Are you talking about something like Nginx?
Owen Hoskins
@owenhoskins
Feb 22 2016 23:28
@pomaking Just took a look, seems the audience field is used within the layout array. The reaction-product-simple registry has the route /product/:handle/:variantId? without an audience or permissions setting, and it is accessible to guest users.