A
A
Alexander2015-10-09 20:29:55
Yii
Alexander, 2015-10-09 20:29:55

How to write php code in JS section?

<?php
$script = <<< JS
$('button.submitButton').click(function(){
myDropzone.processQueue();
});
var mockFile = { name: "Filename", size: 12345 };
myDropzone.options.addedfile.call(myDropzone, mockFile);
myDropzone.options. thumbnail.call(myDropzone, mockFile, "/admin/images/articles/1/e1b3f817204434.5603bb143a908.jpg");
JS;
$this->registerJs($script);
?>

I need to pass this piece of code through foreach
myDropzone.options.addedfile.call(myDropzone, mockFile);
myDropzone.options. thumbnail.call(myDropzone, mockFile, "/admin/images/articles/1/e1b3f817204434.5603bb143a908.jpg");

How to do it ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Pavlenko, 2015-10-09
@kentuck1213

<?php
$script = <<< JS
$('button.submitButton').click(function(){
myDropzone.processQueue();
});
var mockFile = { name: "Filename", size: 12345 };
JS;
foreach($array as $v){
$script.='myDropzone.options.addedfile.call(myDropzone, mockFile);
myDropzone.options. thumbnail.call(myDropzone, mockFile, "/admin/images/articles/1/e1b3f817204434.5603bb143a908.jpg");';
}
$this->registerJs($script);
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question