I have a table in which I dynamically create IDs for divs, using Vue. The code looks like this:
<table>
<tbody>
<tr v-for="(group, index) in groups" >
<td>
<a data-toggle="collapse" :href="'#users-in-'+encodeURIComponent(group.gname)" aria-expanded="false" :aria-controls="'users-in-'+encodeURIComponent(group.gname)" v-text="group.gname"></a>
<div class="collapse" :id="'users-in-'+encodeURIComponent(group.gname)">
<p>some stuffs</p>
</div>
</td>
<td>
<p>Some other stuff</p>
</td>
</tr>
</tbody>
</table>
The idea is to dynamically generate #users-in-someGroupName
div names for each group. Above example works well, but it crashes when I have spaces in group names. In console I get JQuery error:
Error: Syntax error, unrecognized expression: #users-in-some%20group%20with%20space
I added encodeURIComponent
in order to mitigate it, but it seems Vue/JQuery cannot handle this. How can I pass spaces in div names?