How to trigger a function when page is changed in vuejs - html

I am facing a question/issue.
I want to know on how to trigger a function when a page is changed in VUEJS.
Can someone help in some code snippets to make more understandable?
Thank you

Do you want to trigger the function from one page and let it execute on another one?
Otherwise you could use lifecycle hooks as mounted() or created() when page loads. It will trigger a function as soon as page is loaded.

Related

jquery function constant monitoring

Let's say I got the folloning testing html code:
<button class="button is-small is-danger is-light" id="choose">choose</button>
and the following jquery code:
function c3 () { $("#choose").click(function() { alert("clicked")})}
once a click is registered an alert goes of withe the message "clicked".
this happens when the c3 function is executed.
But suppose I want the c3 function to constantly wait for an click event? How do I get the function to constantly monitor the id tag?
ok, I think I now understand how this works. Every time I click on the button the whole page is reloaded and subsequently the jquery function is gone. All my functions reside in a scripts.js file on the server side. The solution is to have the jquery function on the page that is being reloaded.
I hope this is heplfull for others.

Jquery Game-loop Selection Drop-down

Please help, how would you make a timer that runs some code for a time specifed by the user selecting an option from a dropdown menu ? Jquery please.
PS: I tried to attach my code but I'm getting errors (here on the stacks)
Please help, any ideas welcome. I'm really struggling
First of all, to set a "timer" in js in general, you use
setTimeout(() => some_stuff, time_in_ms)
for example, to send a console.log in half a second, you'll use
setTimeout(() => {console.log("hi");}, 500);
So, when the user selects the option from the dropdown menu, just start a timer with the delay as what the user chose, and the function as whatever you want to run.
If you don't already have a dropdown menu, this tutorial might come in handy to create it: https://www.w3schools.com/howto/howto_js_dropdown.asp
But yea, as the comment mentioned, please also send your code, because without it its really hard to give accurate help.

Run JS function (with a refreshed bean parameter) after commandLink's action that moves the user on another page?

This is my first question here and on top of that I'm really, really new to Spring/JSF/RichFaces (about 3 weeks) so, I'm sorry if my question is dumb :)
Long story short, having the following:
a4j:commandLink
action="myBean.doSomething" method that (among other things) updates a JSON parameter and returns another navigation page (so clicking on the commandLink moves the user on another page)
in the above case the oncomplete event does not trigger.
What I need to do is to refresh the JSON parameter so I can use it in a JS function before the user is moved to the next page. Since oncomplete doesn't trigger in my case I had to find a way around it but I am really not sure how "bullet proof" is the way I implemented. (not to mention that it is quite troublesome to implement it all over the place)
What I did so far was to have the commandLink's action point to the bean's method that does everything except returning the new navigation page and on oncomplete event to run my JS function with the updated JSON object then call a previously declared jsFunction that all it does is to return the navigation page.
It works ok, I guess, but I was wondering if there's "an official" (proper) way to do it (like forcing the oncomplete or similar event that comes after the action where I can use javascript).
Here's the example:
<a4j:form id="myForm">
<a4j:jsFunction name="moveToNextPage" action="next_page"/>
<a4j:commandLink action="#{myBean.doLogicAndUpdateJSON}"
oncomplete="callJSfunction(#{myBean.objJSON});moveToNextPage();">
</a4j:commandLink>
</a4j:form>
Thanks!

Google UiApp reset UI Application

I have a script I am making that is essentially a form that submits an email. There is a submit and a reset button. My goal I am hoping to accomplish is the the Reset button either reloads the Google Site, or reloads the App Script.
Is there a function in Google Apps Scripts that I can use to accomplish this?
By putting everything in a panel (horizontal, vertical, scroll, etc), you can do the following in your server handler for your form submit
app = UiApp.getActiveApplication().remove(0);
/*add whatever you want here using app */
return app;
This removes the first item in the app (the panel) and lets you add whatever.
You could also use a client handler with an initially invisible item. On submit, hide the form and show a message until the server handler returns.
Unfortunately, there is no way to refresh the page.
Edit: Adding what I wrote in the comment so it's readable:
The way I usually set mine up, doGet and the handler both call another function with arguments for the new/current app and whatever values my listboxes have. For example,
function doGet(e){
return actuallyCreateGadget(UiApp.createApplication(), "default value for listbox");
}
function actuallyCreateGadget(app, selectedValue){
//do stuff here and finish by returning app
}
function serverHandlerFunction(e){
return actuallyCreateGadget(UiApp.getActiveApplication().remove(0), e.parameter.lbFirst);
}

Asynchronous view call in backbone.js when model is updated

I'm trying to make a demo application for practicing backbone.js.
In my app architecture I first designed the model and inside it wrote a code for parsing a JSON file and storing those records in localStorage and then populating model's attribute hotelsdata with the first 10 records of localStorage.
And then whenever I'm calling the backbone.view.extend() I'm fetching the data from model object.
Now, what I want to do is whenever my model is updated my view must also be updated from the new values in the model. I've already tried
model.on('change',function())
trigger but when I'm calling the view.render() method on the change event my page is being updated, but during the period of adding of records on the page my scroll is not working.
So, can anyone please suggest some way in which I can call that view.render() method asynchronously so that my page's scroll would not be affected during the pressing time of view.render().
In short when my view is being updated the scrolling of the page must work.
I think you have a problem of, how we can call it?, brutal render :)..
I should see your render() method to confirm it, but I think in your render you are removing from the DOM a big portion of the page and then recreating it again. This could cause your scroll to messup. And there is not any asynchronous behavior that can help you.
You should recreate the subelements of your View one by one to have a sweet scroll feeling.
(Show us your render() method if I'm completely confuse)