chuckjones242
chuckjones242

Reputation: 165

Passing jade variables as parameteres to jQuery

A night of fun.

The standard template of

#{media[i+2]._id}

Works most of the time... but being able to pass this spaghetti code into jQuery functions is becoming impossible for me.

Here's the options I've tried:

input.btn.btn-success(onclick='UpdateStatus(#{media[i+2]._id})', type='button', value='Approve')

Will not work. Will give me an illegal token error.

However if I inspect the element it's what I wanted.......

<a href="#" onclick="UpdateStatus(5224207bc90df58486947d70)" class="btn btn-success">Approve</a>

Really stuck guys, thanks for the help!

Rob.

Upvotes: 0

Views: 1251

Answers (2)

Andreas Hultgren
Andreas Hultgren

Reputation: 14953

I think what you really want is:

onclick="UpdateStatus(&quot;5224207bc90df58486947d70&quot;)"

Note the added quotes, since it's not a number but a hex string. Thus:

input.btn.btn-success(onclick='UpdateStatus("#{media[i+2]._id}")', type='button', value='Approve')

Upvotes: 0

reyaner
reyaner

Reputation: 2819

did you try this:

onclick='UpdateStatus("#{media[i+2]._id}")'

Upvotes: 3

Related Questions