bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting Variable (an array) in to Off Canvass with Javascript

AndrewMarkUK opened this issue · comments

I have set a variable called SESSION.store_nav in the hope of making it available throughout the site / app. It's definitely stored, I can, for testing, print_r it to the body of the page and all is present and good.

However, I cannot retrieve this variable when I try using it in a template, which is injected in to a Bootstrap Off-Canvas component.

To clarify: When the user clicks a link, fetch API gets the required template and puts it in to the off-canvas component and then the off-canvas components opens, all works as expected, the template is there but, instead of seeing the repeat region I see the following...

<repeat group="{{@SESSION.store_nav}}" key="{{@cat_key}}" value="{{@cat_list}}">
<div class="col-12 col-sm-6 col-lg-3 <check if='{{@cat_key==1}}'> order-md-last</check>">
    <ul class="list-unstyled">
        <repeat group="{{@cat_list}}" value="{{@list}}">
        <li class="text-nowrap">
            <a href="{{@list.url}}" class="text-dark text-decoration-none">
                <i class="fad fa-store"></i><span>{{@list.Name}}</span>
            </a>
        </li>
        </repeat>
    </ul>
</div>
</repeat>

No html is rendered using the variable I have already set. Its like the content, now inside the Off-Canvas component, doesn't know the variable exists.

Someone is going to tell me I am missing something :-)

Any hints gratefully received.

PS: I assumed because I stored it as SESSION.store_nav it would be available everywhere.

fetch API gets the required template...

the template here must go through the F3 template renderer in order to replace the markup and then sent to the client of course.

class="col-12 col-sm-6 col-lg-3 <check if='{{@cat_key==1}}'> order-md-last</check>"

this looks like weird broken markup. Use a ternary instead:
class="col-12 col-sm-6 col-lg-3 {{@cat_key==1 ? 'order-md-last' : ''}}"

And please join our slack channel or post your issue to google groups or SO, because this is not the right place to discuss frontend issues.. thanks