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

Howto access params variables? #95

Open
niksfirefly opened this issue Jun 3, 2016 · 2 comments
Open

Howto access params variables? #95

niksfirefly opened this issue Jun 3, 2016 · 2 comments

Comments

@niksfirefly
Copy link

I set some variables params in before_action ApplicationController so they are accessible
in entire app for every Paloma controller.

js user: username, email: email

How can i access this params with other js functions outside of Paloma controllers?
I want them to be accessible for all pages - not specific ones.
I see them passed to html-js script, for example:

request = {"resource":"Test","action":"index","params":{"user":"admin","email":"[email protected]"}};

@gnclmorais
Copy link

Hi @niksfirefly!

I don’t think that’s possible… At least, it doesn’t look like something that Paloma supports by default (you seem like you want global variables). Do you want them to be accessible by every JS function in your app, or only every action a Paloma controller might have?
However, have you tried to set those parameters as global variables in other way? Something like:

Paloma.controller('Application', {
  before: ['all -> init'],
  init: function () {
    var params = this.params;

    Object.keys(params).forEach(function (key) {
      window[key] = params[key];
    });
  },
});

It’s not pretty, and I haven’t tested it, honestly. But it’s very close to what I would write for this case, if necessary.

@gnclmorais
Copy link

I just noticed you can also do something like this: https://github.com/kbparagua/paloma#controller-wide-setup

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

No branches or pull requests

2 participants