Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Volt link_to onclick a

Hi @all,

how can i generate this in volt:

            {% for media in %}
                {{ link_to( "onclick" : "return launchEditor(image_1_" ~ media.usersId, media.image_1")", 'class' : 'btn btn-flat btn-default', '<i class="fa fa-picture-o"></i> Bild bearbeiten') }}
            {% endfor %}

I get this message:

Syntax error, unexpected token STRING() in C:\xampp\htdocs\projects\vokuro/app/views/profiles/index.volt on line 30
#0 [internal function]: Phalcon\Mvc\View\Engine\Volt\Compiler->_compileSource('\n{{ content() }...', false)
#1 [internal function]: Phalcon\Mvc\View\Engine\Volt\Compiler->compileFile('C:\\xampp\\htdocs...', 'C:\\xampp\\htdocs...', false)
#2 [internal function]: Phalcon\Mvc\View\Engine\Volt\Compiler->compile('C:\\xampp\\htdocs...')
#3 [internal function]: Phalcon\Mvc\View\Engine\Volt->render('C:\\xampp\\htdocs...', Array, true)
#4 [internal function]: Phalcon\Mvc\View->_engineRender(Array, 'profiles/index', true, true, NULL)
#5 [internal function]: Phalcon\Mvc\View->render('profiles', 'index', Array)
#6 C:\xampp\htdocs\projects\vokuro\public\index.php(33): Phalcon\Mvc\Application->handle()
#7 {main}

edited Sep '15
{{ link_to( "onclick" : "return launchEditor(image_1_" ~ media.usersId ~ ", " ~ media.image_1 ~ ")", 'class' : 'btn btn-flat btn-default', '<i class="fa fa-picture-o"></i> Bild bearbeiten') }}


Hi Andres,

thank you for you help. Your example almost work, i did some changes:

{{ tag_html("a", ["href":"#",'onclick' : 'return launchEditor("image_1_' ~ media.usersId ~    '","' ~media.image_1 ~ '");', 'class' : 'btn btn-flat      btn-default']) }}
    <i class="fa fa-picture-o"></i> Bild bearbeiten
{{ tag_html_close("a") }}

Now it works perfect for me :-)

Kind regards