Vue 2 + Bootstrap-vue - dynamic attribute












2














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



enter image description hereenter image description here



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



enter image description here



Browser console - Chrome



enter image description here










share|improve this question



























    2














    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



    enter image description hereenter image description here



    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



    enter image description here



    Browser console - Chrome



    enter image description here










    share|improve this question

























      2












      2








      2







      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



      enter image description hereenter image description here



      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



      enter image description here



      Browser console - Chrome



      enter image description here










      share|improve this question













      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



      enter image description hereenter image description here



      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



      enter image description here



      Browser console - Chrome



      enter image description here







      vue.js attributes bootstrap-4






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 16 '17 at 16:40









      north.inhalenorth.inhale

      126111




      126111
























          2 Answers
          2






          active

          oldest

          votes


















          1














          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.






          share|improve this answer























          • 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



















          1














          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






          share|improve this answer





















            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            1














            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.






            share|improve this answer























            • 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
















            1














            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.






            share|improve this answer























            • 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














            1












            1








            1






            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.






            share|improve this answer














            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.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            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


















            • 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













            1














            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






            share|improve this answer


























              1














              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






              share|improve this answer
























                1












                1








                1






                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






                share|improve this answer












                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







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 15 '18 at 7:48









                Jan DoleczekJan Doleczek

                13115




                13115






























                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Guess what letter conforming each word

                    Port of Spain

                    Run scheduled task as local user group (not BUILTIN)