grych / drab

Remote controlled frontend framework for Phoenix.

Home Page:https://tg.pl/drab

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Undefined nodrab property

sineed opened this issue · comments

I started using Drab recently and found a small problem related to nodrab js property initialization. On page load I get Uncaught TypeError: Cannot set property 'gm4dcojuha2donjr' of undefined on this line __drab.nodrab['gm4dcojuha2donjr'] = {}; inside drab script tag.

Currently it is fixed by adding

<script type="text/javascript">
  window.__drab.nodrab = {};
</script>

right after <%= Drab.Client.run(@conn) %> call on my template.

Hi @sineed, thanks for reporting!

Hi @sineed,
unfortunately I can't reproduce this issue. Could you please check if you have windows.__drab.assigns?

Drab should initialize both JS properties:

    init_js = """
    if (typeof window.#{@jsvar} == 'undefined') {#{@jsvar}={assigns: {},nodrab: {},properties: {}}};
    if (typeof #{@jsvar}.index == 'undefined') {#{@jsvar}.index = '#{partial_hash}'};
    #{@jsvar}.assigns['#{partial_hash}'] = {};
    #{@jsvar}.nodrab['#{partial_hash}'] = {};
    """

Closing after 28 days as it is not replicable