ENXF NET
Administrator
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P.S Member
S.V.I.P Member
V.I.P Member
Collaborate
Registered
- Joined
- Nov 13, 2018
- Messages
- 25,955
- Points
- 823
Reputation:
How can I pass an array as a data option to javascript?
For example, I have the following in my template:
HTML:
In my controller, I'm passing the following param:
PHP:
In my js file I have the following:
JavaScript:
However, when I console.log(this.options.myArray); I only see Array or null in the log.
Continue reading...
For example, I have the following in my template:
HTML:
data-my-array="{$myArray}"
In my controller, I'm passing the following param:
PHP:
$viewParams = ['myArray' => [0=>'moo', 1=>'moo1', 2=>'moo2']];
In my js file I have the following:
JavaScript:
Code:
options: {
myArray: null,
},
However, when I console.log(this.options.myArray); I only see Array or null in the log.
Continue reading...