Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass options to page and display it #9

Closed
procom opened this issue Apr 1, 2016 · 2 comments
Closed

Pass options to page and display it #9

procom opened this issue Apr 1, 2016 · 2 comments
Labels

Comments

@procom
Copy link

procom commented Apr 1, 2016

Hello,

I would like to pass options to a page with data-href-page-options.
<button data-href-page="details-page" data-href-page-options='{"title": "Hello World"}'>

/details-page/index.js :

ATV.Page.create({
    name: 'DetailsPage',
    template: template,
    WHAT CODE TO RETRIEVE OPTIONS ?
});

/details-page/template.hbs :

<document>
  <productTemplate>
    <banner>
      <stack>
        <title>WHAT CODE TO DISPLAY OPTIONS</title>
      </stack>
    </banner>
  </productTemplate>
</document>

Thanks.

@emadalam
Copy link
Owner

emadalam commented Apr 1, 2016

@procom Your use case is already covered here https://github.com/emadalam/atvjs#custom-options-while-navigation.

Example:

/details-page/index.js

import template from './template.hbs';

ATV.Page.create({
    name: 'details-page',
    template: template,
    ready(options, resolve, reject) {
        // the options object has everything that you pass
        // options.title in your case
        // use it to do some custom operations and then resolve the promise with your final data
        // in your case, you can simply pass the entire options object as data
        resolve(options);
        // or you can fetch data through ajax based on your options
        // then resolve the promise with the provided data
    }
});

/details-page/template.hbs

<document>
  <productTemplate>
    <banner>
      <stack>
        <title>{{ title }}</title>
      </stack>
    </banner>
  </productTemplate>
</document>

Later in some other template you can simply use <button data-href-page="details-page" data-href-page-options='{"title": "Hello World"}'> and atvjs will automatically bind the click handler at runtime to navigate to the details-page.

Let me know if this works, please close the issue if it does. Thanks!

@procom
Copy link
Author

procom commented Apr 1, 2016

Thank you.
All works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants