Clear mounted html in vue.js - vuejs2

I have 2 components. I have some checkboxes in first component.It resides in left side of the Web Page like Nav bar. In second component I would like to load some HTML Div element on the basis of those checkbox. Now I can load the divs while clicking on those checkboxes using below code.
mounted () {
EventBus.$on('change',this.formated);
},
But when I am clicking on a new checkboxes the loaded divs of previous checkboxes will not disappear. I can see both output of current and previous checkboxes as like output of .append() of jQuery.
How can I clear/disappear previous HTML outputs ?

You need use jQuery's clear() on the elements innerHTML which you're appending too. A better approach would be to instead of appending content, use a v-for directive and maintain an array in the data property with the content you want visible. That would be leveraging vue's reactivity for its intended purposes and offer a more flexible implementation.

Related

Vuetify dialog adds new dialog to dom each time it is opened and exon't remove the previous on close

We have a large scale application but in Vue 2, Composition API and Nuxt.
However we load a lot of content in dialogs. After using the application for several minutes you can see a build up of these dialogs in the DOM.
Is there a way for Vuetify to use the existing dialog one instead of creating a new instance.
Or remove the existing one on close?
I can't see anything in the docs or similar issues from other users.
Each v-dialog with a v-model will be added to the DOM first time it's active/opened, then the visibility is changed on subsequent toggles. It's more "expensive" to add and remove DOM elements (size depending on its nested content) than toggle an active class and add a simple overlay. Probably why it's not recommended to nest v-dialog within a v-for loop, the DOM will get too crowded. If the dialog content is interchangeable, you could have one dialog on the page where the content is toggled too.

vue-select v-model reduce not working / Nuxt js Vue js

I'm using vue-select.
When I want to display the selected element, it shows me the value and not the text (see the screen).
I saw on several reports (and on the documentation) that I could use reduce.
I also saw that I could add a ":key" props on the component but that doesn't work either.
Here I choose the item :
Here the selected item, it displays the value and not the text : (Here the problem)
My component file (input-custom.vue) :
My component in page:
Data in page:
I found the solution.
This is my "handleInput" method.
I emit "e.value" but I want to emit the Object, so replace "e.value" => "e"

Vue force component to render to DOM before it is visible

I have a dialog with elements that I want to access before it is visible to the user. However, the dialog contents (Vue component) are only accessible to Vue once the dialog is visible. Is there a way to ensure the elements within my component are rendered to DOM before it is visible?
I have tried variations of nextTick and forceUpdate with no luck.
elements that I want to access before it is visible to the user sounds like you are probably doing something in "not Vue way" but sure, you can have your component rendered in DOM but still not visible by using v-show

Get Dijit from Parent HTML from embedded iframe

I have a dashboard built using dojo dijits. One of the dijit is dojo calendar widget.
In this dashboard I am embedding an iframe to it. I want to change the value of the calendar widget from within the iframe.
The issue is since it is not just about changing the text value in the input box of calendar dijit it is also about calling the on change event. So I am using the following
dijit.byId('dijit_form_DateTextBox_1').set('value', datFrom);
This way the value gets updated as well as the change event is fired.
Now since I want to do this from within the iframe I need to get reference to calendar dijit in parent HTML page.
If this is a simple Javascript I would have used following to get to that DOM Element and change the value.
const targetNode = $('#'+divId, window.parent.document)[0];
But since this is dojo so I am unable to get this as a dijit object. Is there a way to get dijit from Parent page
Since the dataTextBox is inside iframe, it's in different scope, and looks like you are not using dojo in AMD pattern.
What you could do is get the object from iFrame's contentWidow and call byID() like any other function, example
var _dijit = document.getElementById("iframeId").contentWindow.dijit;
var dateTextBox = _dijit.byId('dijit_form_DateTextBox_1');
dateTextBox.set('value', datFrom);
or better is, you just call a global reference your own function rather than taking reference of dijit.

dijit.Menu to be displayed after DOM had been set up

I have set up in Javascript my preferred dijit.Menu which is that far so good.
How am I able to display the dijit.Menu directly after the page starts up in the (with it's position) without any mouse interaction?! I have looked in the API so far and don't find the answers. Will I have to "overwrite" a method?
If yes, which one is it? And what do I have todo???
The widget will not show up until it is parsed by dojo.
You should place fake menu markup inside its dom node:
<div dojoType="dijit.Menu">
<h1>This text is shown after the dom is loaded
and until the menu is parsed and renered</h1>
</div>
As soon as menu is ready, everything you've placed inside menu's dom node will be replaced by actual widget's html.
NON-AMD Version:
dojo.ready(function(){
// The code for all items!
})
DOJO-AMD Version, put the parameters of the modules you like to add, in require as well give them a name in the functions parameters list:
require(["dojo/domReady!"],function(){
//natve code
});