Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v-bind::class should support hyphen to work with Bootstrap #106

Open
rotherfuchs opened this issue Feb 18, 2021 · 1 comment
Open

v-bind::class should support hyphen to work with Bootstrap #106

rotherfuchs opened this issue Feb 18, 2021 · 1 comment

Comments

@rotherfuchs
Copy link

rotherfuchs commented Feb 18, 2021

Twitter Bootstrap classes have hyphens in their names, i.e. is-valid.
Vue supports hyphens by encapsulating classes within quotes:
https://vuejs.org/v2/guide/class-and-style.html#Object-Syntax

<div
  class="static"
  v-bind:class="{ active: isActive, 'text-danger': hasError }"
></div>

widget_tweaks however does not support this currently if I'm not mistaken which makes impossible to use together with bootstrap and Vue, unless you want to render manually.

{% for field in form.visible_fields %}
{% render_field field class="form-control" v-bind::class="{ 'is-valid' : formValid}" %}
{% endfor %}

^ will fail with syntax error

@rotherfuchs
Copy link
Author

rotherfuchs commented Feb 18, 2021

This workaround works for now:

{% with foo="{'is-valid': formValid}" %}
{% render_field field class="form-control" v-bind::class=foo %}
{% endwith %}

or in my case within a form-loop:

{% for field in form.visible_fields %}
{% with vue_bind="{'is-valid': formValid('"|add:field.name|add:"')}" %}
{% render_field field class="form-control" v-bind::class=vue_bind %}
{% endwith %}
{% endfor %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant