Good day,
I am currently using Vue-toastification and I wanted to ask if it's possible to manually end a toast notification? I have searched the docs and I couldn't find it.
My goal is that when another toast notification pops up the 1st one should be deleted. I now have hardcoded timeouts, but the time can vary and it's sometimes not very precise.
Here is my toast.
this.$toast.info("Please hold on a moment, your file is being downloaded.");
I have tried both toast.close() and toast.remove(), but this doesn't yield the expected result.
Thank you for reading this!
use this:
const id = this.$toast.info("Please hold on a moment, your file is being downloaded.")
// dismiss
this.$toast.dismiss(id)
Related
Just like the title says. I want to create a shared online timer for my friends and say when one of my friends clicked the "refresh timer" button, ideally that all my other friends' page should get automatically refreshed with the new timer, or a notification saying that the timer has refreshed and require them to refresh the page.
I think at least the latter one is possible since when you get a comment of your question on Stackoverflow, you will get notified somewhere in the page telling you there's a new comment.
How to achieve this functionality? In JS or? Thanks in advance!
Javascript setInterval
using Javascript setInterval when the page is loaded, if you're not using MySQL, check a notepad for the text update(or whatever you want) and when it's found, clear it and then run whatever code
When the user presses a button, have it write to the file update(the same thing as above)
There would be 2 ways to go about it:
Simpler one would be to use polling through setInterval and look for changes on the backend.
A more accurate way would be to use Websockets which relay information to the clients that the timer has been reset.
Your choice of tool would depend on how complex you're willing to let it be
I'm using introjs.
But when a user ends the intro, then refreshes the page, introjs starts up again.
Is there a way to only show a walkthrough once per user?
For example I have it where when a user first signs into my website - introjs will popup. I only want it to pop up for that initial welcome.
Potential Solutions
Maybe there is a way to trigger introjs via the create action like one would with a flash message?
I could replicate all my header, sidebar, and challenges section code into pages/tutorial.html.erb and make a route www.websitename.com/tutorial, but then that would be a lot of code to duplicate and then whenever I change something in the site I would have to change it in tutorial too.
Is there a way to adjust this javascript method in application.js to trigger only once per user $(function () {
introJs().start() })?
I just use data-intro="" for each step of the walkthrough.
You want your application/webpage to remember that the user has already gone through your tutorial.
There are a few ways you can do that. For a start, you can use cookies or localStorage
The gist is that after the user finishes, or otherwise exits your tutorial, you can store a descriptive value to the user's client, by using one of the above methods, and on page load you should first check if this value exists and act accordingly.
EDIT: As mentioned in comments, you will need a server side approach as well.
I'm working on my webpage, because I want my jobs to be stored on page and I can check them anytime I want.
This is my code at the moment: http://jsfiddle.net/p0cdbozx/
I have already done that you can add any job you need, and you can delete it by clicking on it, also slideUp and slideDown function.
The only thing I can't figure out how to do is WEB STORAGE. I want that informations I type in table will be saved anytime I open the website.
If I am not wrong I should add something like that code:
localStorage.data=$("#table").html();
document.getElementById("table").innerHTML=localStorage.data;
but the problem is I actually don't know where exactly to put it in.
If anyone have minute of time, please check out my problem and help me!
Thanks a lot!
Sorry to burst your bubble, but localStorage only supports strings.
Use JSON.stringify() and JSON.parse() to be able to set and store the data.
To set:
if(typeof localStorage["tableHtml"] !== 'undefined')
$('#table').html(JSON.parse(localStorage["tableHtml"]));
and to store:
localStorage["tableHtml"] = JSON.stringify($('#table').html());
Have a look: http://jsfiddle.net/p0cdbozx/1/
I have a load of chat boxes which come up on click of a username within a list. The problem is I need to know which are currently chosen to hide/show if more are clicked than there is screen space (think of facebook - you keep clicking friends for private message and when no more fit along the bottom, the next one takes the last boxes spot. Clearly you hide this last one, but want it to come back if you close this current choice)
So, I need to cache a list or have a ridiculous number of input boxes in preparation. I have been looking at possibilities and is it possible to implement this with JSON cache? Is there a better option?
If JSON is the best option, please can somebody show me simply:
-> store array of usernames in jquery to JSON cache
-> retrieve JSON cache into jquery array
My JSON knowledge = 0.0001% and this is the only thing I want to use it for for a long time so my jsfiddle attempts failed. If you know any good "beginner / fast skim over" tutorials please link them!
Many thanks as always
Maybe you should look into the HTML5 feature localStorage
localStorage
localStorage How to use it
With that you can save the current username list of your users in their browser and access it easily with javascript.
You can save the data just for the browser session sessionStorage or for longer localStorage, so if the user comes back the next day, his settings will still be set.
First of all, my english skills fell apart during the last years so I hope I can explain my problems exactly.
Im trying to write a garbage calendar app with an alarm, notification and so on if it might be ready some time.
At first you have to choose the right address of your city and due to that I know in which district the user is living and with that information I know when his garbage is being collected.
Right now I have two problems and I really can't fix them.
The first one is when I chose my address I'm coming to the address site where the address is shown and I have two buttons. The first one is: "Wrong address?" and the second one is "show me the dates for this district".
When I'm clicking the second option with the dates I'm calling my function doSomething3(sorry for those names) but if I'm coming to the page where the dates should be shown there is nothing shown on this page.
I figured out when im setting the variable viewModel.bezirksnr in the javascript file and for example navigate from the homescreen to the dates of districts with opening the same function its actualy workin so i guess my function isn't completly wrong.
The second observation I made is when I'm setting the variable, then pushing the button in the homescreen for showing me the dates (is working ofc) and then I'm setting an address and then push the button from my address site to show me the dates then something like this appears:
Every single date of the first attempt(with the variable set before starting the app) is followed by all of the dates of the new chosen district.
The second problem is the performance problems. When I selected an address and maybe I miss clicked and want to select another its not working. The app is so laggy and doesn't react anymore.
Due to this and cause of the pic I uploaded I guess maybe I'm not clearing the arrays in a right way but I tried for example the removeAll() for observable arrays but there was no effect.
Here is my index.html including all those pages:
http://pastebin.com/Zci009cn
And here is my javascript file:
http://pastebin.com/PwBdkBa0
I put them into pastebin for not creating a massive wall of text ;)
I hopefully could explain everything in an understanding way and it would be awesome if anyone can help me! if you have any questions, feel free to ask