Vue 2 + Bootstrap-vue - dynamic attribute
this is my first steps in Vue 2 + bootstrap-vue, and I'm trying to figure out how to dynamically change the name of an attribute, so that at a small screen resolution the tooltip changes its position.
JS code below works fine, but tooltip not changing his position =(
Please help me improve my mistake;
.pug
JS
'use strict';
import Vue from 'vue';
import BootstrapVue from 'bootstrap-vue';
document.addEventListener("DOMContentLoaded", function () {
Vue.use(BootstrapVue);
new Vue({
el: '#freshbroccoli',
data: {
windowWidth: null,
position: this.windowWidth >= 480 ? 'left' : 'bottom'
},
mounted() {
this.$nextTick(function () {
window.addEventListener('resize', this.getWindowWidth);
this.getWindowWidth();
});
},
methods: {
getWindowWidth() {
this.windowWidth = document.documentElement.clientWidth;
console.log('this.windowWidth >= 480 ? 'left' : 'bottom'', this.windowWidth >= 480 ? 'left' : 'bottom', 'n', this.windowWidth);
}
},
beforeDestroy() {
window.removeEventListener('resize', this.getWindowWidth);
}
});
});
Browser - Chrome
Browser console - Chrome
vue.js attributes bootstrap-4
add a comment |
this is my first steps in Vue 2 + bootstrap-vue, and I'm trying to figure out how to dynamically change the name of an attribute, so that at a small screen resolution the tooltip changes its position.
JS code below works fine, but tooltip not changing his position =(
Please help me improve my mistake;
.pug
JS
'use strict';
import Vue from 'vue';
import BootstrapVue from 'bootstrap-vue';
document.addEventListener("DOMContentLoaded", function () {
Vue.use(BootstrapVue);
new Vue({
el: '#freshbroccoli',
data: {
windowWidth: null,
position: this.windowWidth >= 480 ? 'left' : 'bottom'
},
mounted() {
this.$nextTick(function () {
window.addEventListener('resize', this.getWindowWidth);
this.getWindowWidth();
});
},
methods: {
getWindowWidth() {
this.windowWidth = document.documentElement.clientWidth;
console.log('this.windowWidth >= 480 ? 'left' : 'bottom'', this.windowWidth >= 480 ? 'left' : 'bottom', 'n', this.windowWidth);
}
},
beforeDestroy() {
window.removeEventListener('resize', this.getWindowWidth);
}
});
});
Browser - Chrome
Browser console - Chrome
vue.js attributes bootstrap-4
add a comment |
this is my first steps in Vue 2 + bootstrap-vue, and I'm trying to figure out how to dynamically change the name of an attribute, so that at a small screen resolution the tooltip changes its position.
JS code below works fine, but tooltip not changing his position =(
Please help me improve my mistake;
.pug
JS
'use strict';
import Vue from 'vue';
import BootstrapVue from 'bootstrap-vue';
document.addEventListener("DOMContentLoaded", function () {
Vue.use(BootstrapVue);
new Vue({
el: '#freshbroccoli',
data: {
windowWidth: null,
position: this.windowWidth >= 480 ? 'left' : 'bottom'
},
mounted() {
this.$nextTick(function () {
window.addEventListener('resize', this.getWindowWidth);
this.getWindowWidth();
});
},
methods: {
getWindowWidth() {
this.windowWidth = document.documentElement.clientWidth;
console.log('this.windowWidth >= 480 ? 'left' : 'bottom'', this.windowWidth >= 480 ? 'left' : 'bottom', 'n', this.windowWidth);
}
},
beforeDestroy() {
window.removeEventListener('resize', this.getWindowWidth);
}
});
});
Browser - Chrome
Browser console - Chrome
vue.js attributes bootstrap-4
this is my first steps in Vue 2 + bootstrap-vue, and I'm trying to figure out how to dynamically change the name of an attribute, so that at a small screen resolution the tooltip changes its position.
JS code below works fine, but tooltip not changing his position =(
Please help me improve my mistake;
.pug
JS
'use strict';
import Vue from 'vue';
import BootstrapVue from 'bootstrap-vue';
document.addEventListener("DOMContentLoaded", function () {
Vue.use(BootstrapVue);
new Vue({
el: '#freshbroccoli',
data: {
windowWidth: null,
position: this.windowWidth >= 480 ? 'left' : 'bottom'
},
mounted() {
this.$nextTick(function () {
window.addEventListener('resize', this.getWindowWidth);
this.getWindowWidth();
});
},
methods: {
getWindowWidth() {
this.windowWidth = document.documentElement.clientWidth;
console.log('this.windowWidth >= 480 ? 'left' : 'bottom'', this.windowWidth >= 480 ? 'left' : 'bottom', 'n', this.windowWidth);
}
},
beforeDestroy() {
window.removeEventListener('resize', this.getWindowWidth);
}
});
});
Browser - Chrome
Browser console - Chrome
vue.js attributes bootstrap-4
vue.js attributes bootstrap-4
asked Sep 16 '17 at 16:40
north.inhalenorth.inhale
126111
126111
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Edit: my old answer assumed that was a v-b-tooltip
was a component and not a directive.
From what I can tell, using a variable in a directive isn't supported. One solution would be to use vue-popper
since you can update its options dynamically. Bootstrap uses Popper under the hood for its tooltips, so you wouldn't be introducing new technologies this way.
v-b-tooltip is a directive, not a component. OP is trying to add a dynamic modifier to a directive.
– Bert
Sep 16 '17 at 19:02
@Bert Ah, thanks. I'll update my answer.
– Franey
Sep 16 '17 at 19:10
add a comment |
For Bootstrap-Vue tooltip there is parameter placement, so code could look like this:
<b-btn title="Title" target="d150" :placement="position">My btn</b-btn>
More at: https://bootstrap-vue.js.org/docs/components/tooltip
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%2f46256145%2fvue-2-bootstrap-vue-dynamic-attribute%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Edit: my old answer assumed that was a v-b-tooltip
was a component and not a directive.
From what I can tell, using a variable in a directive isn't supported. One solution would be to use vue-popper
since you can update its options dynamically. Bootstrap uses Popper under the hood for its tooltips, so you wouldn't be introducing new technologies this way.
v-b-tooltip is a directive, not a component. OP is trying to add a dynamic modifier to a directive.
– Bert
Sep 16 '17 at 19:02
@Bert Ah, thanks. I'll update my answer.
– Franey
Sep 16 '17 at 19:10
add a comment |
Edit: my old answer assumed that was a v-b-tooltip
was a component and not a directive.
From what I can tell, using a variable in a directive isn't supported. One solution would be to use vue-popper
since you can update its options dynamically. Bootstrap uses Popper under the hood for its tooltips, so you wouldn't be introducing new technologies this way.
v-b-tooltip is a directive, not a component. OP is trying to add a dynamic modifier to a directive.
– Bert
Sep 16 '17 at 19:02
@Bert Ah, thanks. I'll update my answer.
– Franey
Sep 16 '17 at 19:10
add a comment |
Edit: my old answer assumed that was a v-b-tooltip
was a component and not a directive.
From what I can tell, using a variable in a directive isn't supported. One solution would be to use vue-popper
since you can update its options dynamically. Bootstrap uses Popper under the hood for its tooltips, so you wouldn't be introducing new technologies this way.
Edit: my old answer assumed that was a v-b-tooltip
was a component and not a directive.
From what I can tell, using a variable in a directive isn't supported. One solution would be to use vue-popper
since you can update its options dynamically. Bootstrap uses Popper under the hood for its tooltips, so you wouldn't be introducing new technologies this way.
edited Sep 16 '17 at 19:31
answered Sep 16 '17 at 18:46
FraneyFraney
1,15678
1,15678
v-b-tooltip is a directive, not a component. OP is trying to add a dynamic modifier to a directive.
– Bert
Sep 16 '17 at 19:02
@Bert Ah, thanks. I'll update my answer.
– Franey
Sep 16 '17 at 19:10
add a comment |
v-b-tooltip is a directive, not a component. OP is trying to add a dynamic modifier to a directive.
– Bert
Sep 16 '17 at 19:02
@Bert Ah, thanks. I'll update my answer.
– Franey
Sep 16 '17 at 19:10
v-b-tooltip is a directive, not a component. OP is trying to add a dynamic modifier to a directive.
– Bert
Sep 16 '17 at 19:02
v-b-tooltip is a directive, not a component. OP is trying to add a dynamic modifier to a directive.
– Bert
Sep 16 '17 at 19:02
@Bert Ah, thanks. I'll update my answer.
– Franey
Sep 16 '17 at 19:10
@Bert Ah, thanks. I'll update my answer.
– Franey
Sep 16 '17 at 19:10
add a comment |
For Bootstrap-Vue tooltip there is parameter placement, so code could look like this:
<b-btn title="Title" target="d150" :placement="position">My btn</b-btn>
More at: https://bootstrap-vue.js.org/docs/components/tooltip
add a comment |
For Bootstrap-Vue tooltip there is parameter placement, so code could look like this:
<b-btn title="Title" target="d150" :placement="position">My btn</b-btn>
More at: https://bootstrap-vue.js.org/docs/components/tooltip
add a comment |
For Bootstrap-Vue tooltip there is parameter placement, so code could look like this:
<b-btn title="Title" target="d150" :placement="position">My btn</b-btn>
More at: https://bootstrap-vue.js.org/docs/components/tooltip
For Bootstrap-Vue tooltip there is parameter placement, so code could look like this:
<b-btn title="Title" target="d150" :placement="position">My btn</b-btn>
More at: https://bootstrap-vue.js.org/docs/components/tooltip
answered Nov 15 '18 at 7:48
Jan DoleczekJan Doleczek
13115
13115
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f46256145%2fvue-2-bootstrap-vue-dynamic-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