Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142327

How to include ruby code in a Javascript String

$
0
0

I am making a function that on click it will append more date fields. Although the 'form' tag keeps getting outputted by the file and failing.

 $('.add-date-btn').click(function(e) {
        e.preventDefault()

        console.log('btn clicked')

        var appendStr = '<div class="form-group classes-field-one-time date-field">' +
                          '<label>If recurring once: <br />Add Date</label>' +
                          '<%= form.date_field :event_date, :class => 'form-control' %>' +
                          '</div>'


        $('#recurring-dates').append(appendStr)
    })

The line "form.date_field" is what is failing. How can I add this to a string?


Viewing all articles
Browse latest Browse all 142327

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>