{"id":428,"date":"2025-05-05T10:59:13","date_gmt":"2025-05-05T15:59:13","guid":{"rendered":"https:\/\/www.mariomorocho.com\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/"},"modified":"2025-05-05T10:59:13","modified_gmt":"2025-05-05T15:59:13","slug":"to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2","status":"publish","type":"post","link":"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/","title":{"rendered":"To use a b-modal (buefy) as child component managed from parent component on VUE 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">If you need to create a child component that has a b-model which will be managed from parent component, you have to wirte it as:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Child Component<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This component has the <code>b-modal<\/code> and receives the <code>prop<\/code> bool <code>show<\/code> to control their visibility. Moreover, this will emit an event when the modal is closed:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template&gt;\n  &lt;b-modal :active.sync=\"localShow\" has-modal-card @close=\"closeModal\"&gt;\n    &lt;div class=\"modal-card\"&gt;\n      &lt;header class=\"modal-card-head\"&gt;\n        &lt;p class=\"modal-card-title\"&gt;Modal Hijo&lt;\/p&gt;\n      &lt;\/header&gt;\n      &lt;section class=\"modal-card-body\"&gt;\n        &lt;p&gt;Contenido del modal&lt;\/p&gt;\n      &lt;\/section&gt;\n      &lt;footer class=\"modal-card-foot\"&gt;\n        &lt;b-button @click=\"closeModal\"&gt;Cerrar&lt;\/b-button&gt;\n      &lt;\/footer&gt;\n    &lt;\/div&gt;\n  &lt;\/b-modal&gt;\n&lt;\/template&gt;\n\n&lt;script&gt;\nexport default {\n  name: \"ChildModal\",\n  props: {\n    show: {\n      type: Boolean,\n      default: false,\n    },\n  },\n  data() {\n    return {\n      localShow: this.show,\n    };\n  },\n  watch: {\n    show(val) {\n      this.localShow = val;\n    },\n    localShow(val) {\n      if (!val) {\n        this.$emit('close');\n      }\n    }\n  },\n  methods: {\n    closeModal() {\n      this.localShow = false;\n    },\n  },\n};\n&lt;\/script&gt;\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Parent Component<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It controls when the modal is showed or is closed.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template&gt;\n  &lt;div&gt;\n    &lt;b-button @click=\"showModal = true\"&gt;Abrir Modal&lt;\/b-button&gt;\n\n    &lt;child-modal :show=\"showModal\" @close=\"showModal = false\" \/&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n\n&lt;script&gt;\nimport ChildModal from '.\/ChildModal.vue';\n\nexport default {\n  name: \"ParentComponent\",\n  components: {\n    ChildModal,\n  },\n  data() {\n    return {\n      showModal: false,\n    };\n  },\n};\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">&#x1f9e0; Explanation:<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>:show=\"showModal\"<\/code> \u2192 father gives the open sign.<\/li>\n\n\n\n<li><code>@close=\"showModal = false\"<\/code> \u2192 child component emit the close sign.<\/li>\n\n\n\n<li>In child component, it is used <code>.sync<\/code> on <code>:active<\/code> of <code>b-modal<\/code> to do bidirectional binding, but it is only at internal level (<code>localShow<\/code>).<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>If you need to create a child component that has a b-model which will be managed from parent component, you have to wirte it as: &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-428","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>To use a b-modal (buefy) as child component managed from parent component on VUE 2 - Mario Morocho<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"To use a b-modal (buefy) as child component managed from parent component on VUE 2 - Mario Morocho\" \/>\n<meta property=\"og:description\" content=\"If you need to create a child component that has a b-model which will be managed from parent component, you have to wirte it as: &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Mario Morocho\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-05T15:59:13+00:00\" \/>\n<meta name=\"author\" content=\"Mario Morocho\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mario Morocho\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/\"},\"author\":{\"name\":\"Mario Morocho\",\"@id\":\"https:\/\/www.mariomorocho.com\/#\/schema\/person\/f199db712f8241f07898152f31947142\"},\"headline\":\"To use a b-modal (buefy) as child component managed from parent component on VUE 2\",\"datePublished\":\"2025-05-05T15:59:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/\"},\"wordCount\":110,\"publisher\":{\"@id\":\"https:\/\/www.mariomorocho.com\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/\",\"url\":\"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/\",\"name\":\"To use a b-modal (buefy) as child component managed from parent component on VUE 2 - Mario Morocho\",\"isPartOf\":{\"@id\":\"https:\/\/www.mariomorocho.com\/#website\"},\"datePublished\":\"2025-05-05T15:59:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\/\/www.mariomorocho.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"To use a b-modal (buefy) as child component managed from parent component on VUE 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.mariomorocho.com\/#website\",\"url\":\"https:\/\/www.mariomorocho.com\/\",\"name\":\"Mario Morocho\",\"description\":\"Tengo pasi\u00f3n por la tecnolog\u00eda, los proyectos y el liderazgo. Soy el Fundador y CEO de YAKINDU. He liderado varios proyectos tecnol\u00f3gicos para empresas p\u00fablicas y privadas. Creo que el Ecuador puede transformarse digitalmente para ser mas competitivos y entregar valor al mundo.\",\"publisher\":{\"@id\":\"https:\/\/www.mariomorocho.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.mariomorocho.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.mariomorocho.com\/#organization\",\"name\":\"Mario Morocho\",\"url\":\"https:\/\/www.mariomorocho.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.mariomorocho.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.mariomorocho.com\/wp-content\/uploads\/2022\/01\/logo-claro.png\",\"contentUrl\":\"https:\/\/www.mariomorocho.com\/wp-content\/uploads\/2022\/01\/logo-claro.png\",\"width\":512,\"height\":118,\"caption\":\"Mario Morocho\"},\"image\":{\"@id\":\"https:\/\/www.mariomorocho.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.mariomorocho.com\/#\/schema\/person\/f199db712f8241f07898152f31947142\",\"name\":\"Mario Morocho\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.mariomorocho.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8d42df3a727ee0d5cecd994fe9e808b429e5e7c165fbbee315bc7852dfa68641?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8d42df3a727ee0d5cecd994fe9e808b429e5e7c165fbbee315bc7852dfa68641?s=96&d=mm&r=g\",\"caption\":\"Mario Morocho\"},\"description\":\"Director de Innovaci\u00f3n en YAKINDU.\",\"sameAs\":[\"http:\/\/www.yakindu.ec\"],\"url\":\"https:\/\/www.mariomorocho.com\/en\/author\/administrador\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"To use a b-modal (buefy) as child component managed from parent component on VUE 2 - Mario Morocho","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/","og_locale":"en_US","og_type":"article","og_title":"To use a b-modal (buefy) as child component managed from parent component on VUE 2 - Mario Morocho","og_description":"If you need to create a child component that has a b-model which will be managed from parent component, you have to wirte it as: &hellip;","og_url":"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/","og_site_name":"Mario Morocho","article_published_time":"2025-05-05T15:59:13+00:00","author":"Mario Morocho","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Mario Morocho","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/#article","isPartOf":{"@id":"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/"},"author":{"name":"Mario Morocho","@id":"https:\/\/www.mariomorocho.com\/#\/schema\/person\/f199db712f8241f07898152f31947142"},"headline":"To use a b-modal (buefy) as child component managed from parent component on VUE 2","datePublished":"2025-05-05T15:59:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/"},"wordCount":110,"publisher":{"@id":"https:\/\/www.mariomorocho.com\/#organization"},"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/","url":"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/","name":"To use a b-modal (buefy) as child component managed from parent component on VUE 2 - Mario Morocho","isPartOf":{"@id":"https:\/\/www.mariomorocho.com\/#website"},"datePublished":"2025-05-05T15:59:13+00:00","breadcrumb":{"@id":"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.mariomorocho.com\/en\/to-use-a-b-modal-buefy-as-child-component-managed-from-parent-component-on-vue-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/www.mariomorocho.com\/"},{"@type":"ListItem","position":2,"name":"To use a b-modal (buefy) as child component managed from parent component on VUE 2"}]},{"@type":"WebSite","@id":"https:\/\/www.mariomorocho.com\/#website","url":"https:\/\/www.mariomorocho.com\/","name":"Mario Morocho","description":"Tengo pasi\u00f3n por la tecnolog\u00eda, los proyectos y el liderazgo. Soy el Fundador y CEO de YAKINDU. He liderado varios proyectos tecnol\u00f3gicos para empresas p\u00fablicas y privadas. Creo que el Ecuador puede transformarse digitalmente para ser mas competitivos y entregar valor al mundo.","publisher":{"@id":"https:\/\/www.mariomorocho.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mariomorocho.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mariomorocho.com\/#organization","name":"Mario Morocho","url":"https:\/\/www.mariomorocho.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mariomorocho.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.mariomorocho.com\/wp-content\/uploads\/2022\/01\/logo-claro.png","contentUrl":"https:\/\/www.mariomorocho.com\/wp-content\/uploads\/2022\/01\/logo-claro.png","width":512,"height":118,"caption":"Mario Morocho"},"image":{"@id":"https:\/\/www.mariomorocho.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.mariomorocho.com\/#\/schema\/person\/f199db712f8241f07898152f31947142","name":"Mario Morocho","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mariomorocho.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8d42df3a727ee0d5cecd994fe9e808b429e5e7c165fbbee315bc7852dfa68641?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8d42df3a727ee0d5cecd994fe9e808b429e5e7c165fbbee315bc7852dfa68641?s=96&d=mm&r=g","caption":"Mario Morocho"},"description":"Director de Innovaci\u00f3n en YAKINDU.","sameAs":["http:\/\/www.yakindu.ec"],"url":"https:\/\/www.mariomorocho.com\/en\/author\/administrador\/"}]}},"_links":{"self":[{"href":"https:\/\/www.mariomorocho.com\/en\/wp-json\/wp\/v2\/posts\/428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mariomorocho.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mariomorocho.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mariomorocho.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mariomorocho.com\/en\/wp-json\/wp\/v2\/comments?post=428"}],"version-history":[{"count":0,"href":"https:\/\/www.mariomorocho.com\/en\/wp-json\/wp\/v2\/posts\/428\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.mariomorocho.com\/en\/wp-json\/wp\/v2\/media?parent=428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mariomorocho.com\/en\/wp-json\/wp\/v2\/categories?post=428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mariomorocho.com\/en\/wp-json\/wp\/v2\/tags?post=428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}