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

it is possible to parse [object Object] to a javascript object? #48

Closed
secato opened this issue May 16, 2018 · 3 comments
Closed

it is possible to parse [object Object] to a javascript object? #48

secato opened this issue May 16, 2018 · 3 comments

Comments

@secato
Copy link

secato commented May 16, 2018

it is possible to parse a edge object to normal javascript object?
I am trying to pass a object to "data" attribute from datatables plugin

My .edge template

 var myTable = $('#dataTable').DataTable({
            dom: 'tpi',
            data: {{data}},
            columns: [
                @each(item in colunas)
                    { data: '{{item}}'},
                @endeach
            ]
 })

The result:

 var myTable = $('#dataTable').DataTable({
            dom: 'tpi',
            data: [object Object], //HERE IS THE PROBLEM 
            columns: [
                    { data: 'id'},
                    { data: 'name'},
                    { data: 'description'}
            ]
 })
@thetutlage
Copy link
Member

thetutlage commented May 16, 2018

You need to say, {{ toJSON(data) }}.

@mosheYakov
Copy link

{{ toJSON(data) }} does indeed output the object but it converts quotes to &quote;

PSG.test = {{toJSON(test)}}

becomes:

PSG.test = {
  "id": 23,
  "desc": "testing a test"
}

@mosheYakov
Copy link

{{{ toJSON(data) }}} does work!

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

3 participants