How to send values from form.php to view.js?

Permalink
I have very simple script for mansory grid gallery. I want to control the number of cols from the form. "The problem" i dont know how to set the values dynamic like this.

Install like this:
<script type="text/javascript">
   Macy.init({
   container: '#macy-container',
   margin: 12,
   columns: 3,
   }
});   
</script>


If i install the script inside view.php it wont work. Get error:
"1087 Uncaught ReferenceError: Macy is not defined(…)"

siton
 
JohntheFish replied on at Permalink Reply
JohntheFish
There are several ways to do it. This is just one.

Attach them to a dom element as data attribute data-whatever="value", either individually or as a json string. Then in your js, look for the attribute and get the values from it.
siton replied on at Permalink Reply
siton
Nice idea. Do you have some code example (i use jquery)?