Rails: v-model VueJS attribute
Inside a form tag i'm placing a hidden_field.
This hidden_field should have a "v-model" attribute.
I've tried all I can think about:
# nothing shows up
= f.hidden_field :model_attribute, "v-model" => "value"
# that's the one I love the most: it compiles v="{:model=>"value"}"
= f.hidden_field :model_attribute, v: { model: "value" }
# it compiles with the underscore
= f.hidden_field :model_attribute, v_model: "value"
# this throws a compile error, obviously
= f.hidden_field :model_attribute, v-model: "value"
# guess the compiled outcome?
= f.hidden_field :model_attribute, html: { "v-model" => "value" }
#same as previous
= f.hidden_field :model_attribute, options: { "v-model" => "value" }
is rails screwing with me?
Can anyone help me?
ruby-on-rails
add a comment |
Inside a form tag i'm placing a hidden_field.
This hidden_field should have a "v-model" attribute.
I've tried all I can think about:
# nothing shows up
= f.hidden_field :model_attribute, "v-model" => "value"
# that's the one I love the most: it compiles v="{:model=>"value"}"
= f.hidden_field :model_attribute, v: { model: "value" }
# it compiles with the underscore
= f.hidden_field :model_attribute, v_model: "value"
# this throws a compile error, obviously
= f.hidden_field :model_attribute, v-model: "value"
# guess the compiled outcome?
= f.hidden_field :model_attribute, html: { "v-model" => "value" }
#same as previous
= f.hidden_field :model_attribute, options: { "v-model" => "value" }
is rails screwing with me?
Can anyone help me?
ruby-on-rails
1
It looks like the field helpers in rails 5.1+ enforce html5 compatibility, since you are using an invalid field, I don't think you can build the element using the helper, you'd need to write out the entire html tag.
– DivXZero
Nov 19 '18 at 20:31
You should think about why you want that hyphen, and whether or not you need it. I bet you have spent more time than you care to mention on this when you could have just used an underscore. So why not use an underscore?
– Carl Markham
Nov 19 '18 at 20:41
to bind the vuejs to some field, one must use the "v-model" attribute. the underscore option is a fallback for when you are using data attributes, isn't it?
– Rafael Ravena Vicente
Nov 19 '18 at 20:47
add a comment |
Inside a form tag i'm placing a hidden_field.
This hidden_field should have a "v-model" attribute.
I've tried all I can think about:
# nothing shows up
= f.hidden_field :model_attribute, "v-model" => "value"
# that's the one I love the most: it compiles v="{:model=>"value"}"
= f.hidden_field :model_attribute, v: { model: "value" }
# it compiles with the underscore
= f.hidden_field :model_attribute, v_model: "value"
# this throws a compile error, obviously
= f.hidden_field :model_attribute, v-model: "value"
# guess the compiled outcome?
= f.hidden_field :model_attribute, html: { "v-model" => "value" }
#same as previous
= f.hidden_field :model_attribute, options: { "v-model" => "value" }
is rails screwing with me?
Can anyone help me?
ruby-on-rails
Inside a form tag i'm placing a hidden_field.
This hidden_field should have a "v-model" attribute.
I've tried all I can think about:
# nothing shows up
= f.hidden_field :model_attribute, "v-model" => "value"
# that's the one I love the most: it compiles v="{:model=>"value"}"
= f.hidden_field :model_attribute, v: { model: "value" }
# it compiles with the underscore
= f.hidden_field :model_attribute, v_model: "value"
# this throws a compile error, obviously
= f.hidden_field :model_attribute, v-model: "value"
# guess the compiled outcome?
= f.hidden_field :model_attribute, html: { "v-model" => "value" }
#same as previous
= f.hidden_field :model_attribute, options: { "v-model" => "value" }
is rails screwing with me?
Can anyone help me?
ruby-on-rails
ruby-on-rails
edited Nov 21 '18 at 16:21


7urkm3n
3,49221231
3,49221231
asked Nov 19 '18 at 20:24
Rafael Ravena VicenteRafael Ravena Vicente
7316
7316
1
It looks like the field helpers in rails 5.1+ enforce html5 compatibility, since you are using an invalid field, I don't think you can build the element using the helper, you'd need to write out the entire html tag.
– DivXZero
Nov 19 '18 at 20:31
You should think about why you want that hyphen, and whether or not you need it. I bet you have spent more time than you care to mention on this when you could have just used an underscore. So why not use an underscore?
– Carl Markham
Nov 19 '18 at 20:41
to bind the vuejs to some field, one must use the "v-model" attribute. the underscore option is a fallback for when you are using data attributes, isn't it?
– Rafael Ravena Vicente
Nov 19 '18 at 20:47
add a comment |
1
It looks like the field helpers in rails 5.1+ enforce html5 compatibility, since you are using an invalid field, I don't think you can build the element using the helper, you'd need to write out the entire html tag.
– DivXZero
Nov 19 '18 at 20:31
You should think about why you want that hyphen, and whether or not you need it. I bet you have spent more time than you care to mention on this when you could have just used an underscore. So why not use an underscore?
– Carl Markham
Nov 19 '18 at 20:41
to bind the vuejs to some field, one must use the "v-model" attribute. the underscore option is a fallback for when you are using data attributes, isn't it?
– Rafael Ravena Vicente
Nov 19 '18 at 20:47
1
1
It looks like the field helpers in rails 5.1+ enforce html5 compatibility, since you are using an invalid field, I don't think you can build the element using the helper, you'd need to write out the entire html tag.
– DivXZero
Nov 19 '18 at 20:31
It looks like the field helpers in rails 5.1+ enforce html5 compatibility, since you are using an invalid field, I don't think you can build the element using the helper, you'd need to write out the entire html tag.
– DivXZero
Nov 19 '18 at 20:31
You should think about why you want that hyphen, and whether or not you need it. I bet you have spent more time than you care to mention on this when you could have just used an underscore. So why not use an underscore?
– Carl Markham
Nov 19 '18 at 20:41
You should think about why you want that hyphen, and whether or not you need it. I bet you have spent more time than you care to mention on this when you could have just used an underscore. So why not use an underscore?
– Carl Markham
Nov 19 '18 at 20:41
to bind the vuejs to some field, one must use the "v-model" attribute. the underscore option is a fallback for when you are using data attributes, isn't it?
– Rafael Ravena Vicente
Nov 19 '18 at 20:47
to bind the vuejs to some field, one must use the "v-model" attribute. the underscore option is a fallback for when you are using data attributes, isn't it?
– Rafael Ravena Vicente
Nov 19 '18 at 20:47
add a comment |
1 Answer
1
active
oldest
votes
When asking a question. You have to mention, it's VueJS attribute.
Check this LINK
= f.hidden_field :model_attribute, "v-model": "val"
the expected rendering is <input type="hidden" name="model_class[model_attribute]" id="model_class_model_attribute" v-model="value" value=""/>, no data attributes needed.
– Rafael Ravena Vicente
Nov 19 '18 at 21:00
@RafaelRavenaVicente updated my post check it
– 7urkm3n
Nov 19 '18 at 23:54
yeah, it works great on select, text_field... just had trouble with rendering it on a hidden_field... just posted the question here when I was done trying to do it...
– Rafael Ravena Vicente
Nov 21 '18 at 18:30
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53382106%2frails-v-model-vuejs-attribute%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
When asking a question. You have to mention, it's VueJS attribute.
Check this LINK
= f.hidden_field :model_attribute, "v-model": "val"
the expected rendering is <input type="hidden" name="model_class[model_attribute]" id="model_class_model_attribute" v-model="value" value=""/>, no data attributes needed.
– Rafael Ravena Vicente
Nov 19 '18 at 21:00
@RafaelRavenaVicente updated my post check it
– 7urkm3n
Nov 19 '18 at 23:54
yeah, it works great on select, text_field... just had trouble with rendering it on a hidden_field... just posted the question here when I was done trying to do it...
– Rafael Ravena Vicente
Nov 21 '18 at 18:30
add a comment |
When asking a question. You have to mention, it's VueJS attribute.
Check this LINK
= f.hidden_field :model_attribute, "v-model": "val"
the expected rendering is <input type="hidden" name="model_class[model_attribute]" id="model_class_model_attribute" v-model="value" value=""/>, no data attributes needed.
– Rafael Ravena Vicente
Nov 19 '18 at 21:00
@RafaelRavenaVicente updated my post check it
– 7urkm3n
Nov 19 '18 at 23:54
yeah, it works great on select, text_field... just had trouble with rendering it on a hidden_field... just posted the question here when I was done trying to do it...
– Rafael Ravena Vicente
Nov 21 '18 at 18:30
add a comment |
When asking a question. You have to mention, it's VueJS attribute.
Check this LINK
= f.hidden_field :model_attribute, "v-model": "val"
When asking a question. You have to mention, it's VueJS attribute.
Check this LINK
= f.hidden_field :model_attribute, "v-model": "val"
edited Nov 20 '18 at 14:30
answered Nov 19 '18 at 20:44


7urkm3n7urkm3n
3,49221231
3,49221231
the expected rendering is <input type="hidden" name="model_class[model_attribute]" id="model_class_model_attribute" v-model="value" value=""/>, no data attributes needed.
– Rafael Ravena Vicente
Nov 19 '18 at 21:00
@RafaelRavenaVicente updated my post check it
– 7urkm3n
Nov 19 '18 at 23:54
yeah, it works great on select, text_field... just had trouble with rendering it on a hidden_field... just posted the question here when I was done trying to do it...
– Rafael Ravena Vicente
Nov 21 '18 at 18:30
add a comment |
the expected rendering is <input type="hidden" name="model_class[model_attribute]" id="model_class_model_attribute" v-model="value" value=""/>, no data attributes needed.
– Rafael Ravena Vicente
Nov 19 '18 at 21:00
@RafaelRavenaVicente updated my post check it
– 7urkm3n
Nov 19 '18 at 23:54
yeah, it works great on select, text_field... just had trouble with rendering it on a hidden_field... just posted the question here when I was done trying to do it...
– Rafael Ravena Vicente
Nov 21 '18 at 18:30
the expected rendering is <input type="hidden" name="model_class[model_attribute]" id="model_class_model_attribute" v-model="value" value=""/>, no data attributes needed.
– Rafael Ravena Vicente
Nov 19 '18 at 21:00
the expected rendering is <input type="hidden" name="model_class[model_attribute]" id="model_class_model_attribute" v-model="value" value=""/>, no data attributes needed.
– Rafael Ravena Vicente
Nov 19 '18 at 21:00
@RafaelRavenaVicente updated my post check it
– 7urkm3n
Nov 19 '18 at 23:54
@RafaelRavenaVicente updated my post check it
– 7urkm3n
Nov 19 '18 at 23:54
yeah, it works great on select, text_field... just had trouble with rendering it on a hidden_field... just posted the question here when I was done trying to do it...
– Rafael Ravena Vicente
Nov 21 '18 at 18:30
yeah, it works great on select, text_field... just had trouble with rendering it on a hidden_field... just posted the question here when I was done trying to do it...
– Rafael Ravena Vicente
Nov 21 '18 at 18:30
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53382106%2frails-v-model-vuejs-attribute%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
It looks like the field helpers in rails 5.1+ enforce html5 compatibility, since you are using an invalid field, I don't think you can build the element using the helper, you'd need to write out the entire html tag.
– DivXZero
Nov 19 '18 at 20:31
You should think about why you want that hyphen, and whether or not you need it. I bet you have spent more time than you care to mention on this when you could have just used an underscore. So why not use an underscore?
– Carl Markham
Nov 19 '18 at 20:41
to bind the vuejs to some field, one must use the "v-model" attribute. the underscore option is a fallback for when you are using data attributes, isn't it?
– Rafael Ravena Vicente
Nov 19 '18 at 20:47