Is there a way of Vue transition to keep at the of transition end of the old component before new data loaded - ajax

As the title described.
Is there a way of Vue transition to keep at the of transition end of the old component before new data loaded ?
eg. some component, of 2 data model, show as 2 page. Using Vue transition, to remove the old component containing the old data model while AJAX loading the new data, then show the new component with newly loaded data model. ie. do the component switching transition and the AJAX loading at the same time, not to show the new component's entering transition before data loaded.
Want to keep the old component at transition end status, while waiting for the new data AJAX loading. Welcome answers.

Related

Data-view is not updating when entity is updated in Mendix

Question is: How to show data in data-view in such a way that if entity is updated some how dataview is updated too.
This is my Entity named latestReading.
Here is my page LatestReading that show latest readings. It contains three data views.
This page is not called directly, as it expect a object latestReading. Hence a micro-flow named showLatestReadingPage is executed that fetches or create latestReading object and pass it to the LatestReading page and display LatestReading page.
Here is that micro-flow.
getOrCreateLatestReading is a micro-flow that returns us the a latestReading object if it is available or create a new latestReading object if it is not already created and then returns it.
Here is that micro-flow.
These are the properties of first of the three data-views in LatestReading page as shown diagram of LatestReading Page above. Name of this DataView is TemperatureDataView
These are the properties of text widget that is inside TemperatureDataView data-view. Its name is temperatureText. It shows value of temperature in the TemperatureDataView.
And this is the caption of temperatureText text widget:
Problem is when another micro-flow updates the value of latestReading the text widget is not updated. I need to reload it by clicking on navigation link of LatestReading page again.
I need my text widget in data view to keep updating value of latestReading when it is updated my some other micro-flow
The issue is that ‘refresh in client’ only works if the microflow is executed in the same context as the page (client) that the user is seeing. For example if there is a button on the page that triggers a microflow that refreshes the client then it will update the widget. However, if the microflow is triggered by the system (e.g. a scheduled event) then these changes are in a different context. Also if another user triggers a refresh it will only refresh that user’s client. Also if one user is logged in through multiple browsers (i.e. has multiple sessions, it also means that for each session there is a different user context.
The simplest solution in this case would likely be to use an appstore widget that periodically triggers a refresh on the object displayed in the dataview, such as this one: https://appstore.home.mendix.com/link/app/27/ . Simply create nanoflow or microflow with a change action that changes no attributes but refreshes the object.

What's the correct way of doing API requests in React for components that update?

I have two components: App and Movie. In my App component I show a list of movie ID's (they come from my local database), and in the Movie component I show a detailed view of the Movie ID that has been clicked.
Inside the Movie component I fetch some data from the IMDB API for the matching ID. The movie ID gets passed to the Movie as a prop.
No Movie component is shown by default. If a Movie ID is clicked, the Movie component is shown. Once it is shown, another Movie ID can be clicked from the list and the Movie component must be updated with the newly fetched data from the API.
What is the correct way of doing the API requests? If I do it in componentDidMount(), then an API request will only happen the first time the Movie component renders. If I do it in componentWillReceiveProps(), then the Movie component only does the request if it got updated after it has rendered. Is it okay to just use both componentDidMount and componentWillReceiveProps? Or is there a more appropriate way?
Try using componentWillMount which will be fired before the component has mounted.
Here is a good guide regarding component lifecycle.

Wants to display the cursor busy for more time

I have a web page with 9 drop downs and a kendo grid.I am making the ajax call for all drop downs.When I load the page the values in the drop downs gets loaded vary slow with some default values.During the loading period of drop downs I want to show the cursor for kendo grid to be wait.Cursor as a wait is coming but disappearing very soon .I want to show the cursor to be wait until all the drop down gets loaded so that user cannot make any selection in any of the drop down.
Here is my JavaScript code:
function ShowLoadingCursor() {
$("body").css("cursor", "wait");
overlay.show();
overlay.appendTo(document.body);
$('.popup').show();
}
function HideLoadingCursor() {
$('.popup').hide();
overlay.appendTo(document.body).remove();
$("body").css("cursor", "auto");
}
$(document).ready(function () {
ShowLoadingCursor();
});
$(window).load(function () {
HideLoadingCursor();
});
I am using MVC approach.I have uncountable number of web pages.It is impossible to implement the code in all pages.So I am writing the above code in Layout.cshtml page.I can't hard code any drop down id or grid id.Only thing is in all pages i want to display the cursor to be wait until all drop down gets loaded.Any help will be appreciated.
Your central problem is you a not working with the display model as designed. The idea behind doing AJAX/MVC/JSON web technology, is that each part of the page makes its own call to the server, and individually, the parts report ready when they get done rendering their responses. That way, if part of the page takes a long time to get, the user can interact with the rest of the page in the intervening time. The paradigm you are using was designed to do the opposite of what you are trying to do. My advice to you is to thoroughly examine this requirement. You should find a way to not do this.
When the page is loaded change the cursor's style to wait.
Tap into the DataBound event of the Last DropDownList that is loaded. This will fire when the ddl is finished loading it's data.
//kendo dropdowncode
.Events(events => events.DataBound("onDataBound").
function onDataBound()
{
//remove wait cursor and replace with default mouse cursor
}
EDIT:
You can place the JS functions that will handle the change of the cursor in the _Layout.cshtml page, any view that uses that shared layout will have access to those functions.
As far as your Kendo Grids are concerned, you will have to register the event manually for each grid. Your JS functions will be in shared layout so you don't have to worry about adding them again. One other suggestion would be to not to use AJAX to fill the dropdowns, and "pre populate" them before the view renders. I'm not sure of any other way of doing this.

Update d3 chart with newly inserted data in a Meteor collection after form submission

My Meteor application is somewhat simple and displays a d3 chart generated with server calculated data stored in a newly inserted mongodb document:
the user fills a simple form and clicks the submit button
the server does some async work and CPU intensive calculation using the form data
a new Calculus document with 2 fields (formData and calculatedResult) is inserted in a mongodb Calculi collection
the SVG chart is updated with the newly calculated data
Despite reading the Meteor parties example which makes use of d3, this tutorial on using d3 and Meteor to generate SVG and this screencast on how to build a reactive data source, I'm getting really confused! I'm getting a hard time properly understanding reactive data sources, templates and dependencies in Meteor.
I can't seem to be able to make the SVG chart updates after a new Calculus document is inserted.
Here's my question: what's a comprehensive, newbie-friendly way to automatically update a d3 generated SVG chart with server-calculated data received after submitting a form that inserts a document in a collection?
You either need to have the user subscribe to changes in the Calculi collection (http://docs.meteor.com/#reactivity), or if you're rendering in a template the user's response you can make and call an update() method that runs your d3 code. This will update your charts in the update portion of the d3 code.

Django delayed updates to database

I'm creating a Django/JQuery/MySQL application where I pass a composite data structure 'grid' as
return render_to_response('products.html', grid)
I render 'grid' into a set of UI elements ('td', 'button', 'div' etc. encapsulated in a HTML 'table'.
A typical use case:
User clicks on a certain UI element in the table
jQUery.click() is called which creates a inner 'input' tag for the clicked element.
User can add/modify/delete text from the element.
When focus is lost, jQuery.blur() is called which reverts the original properties of the clicked element such as removing input tag etc.
jQuery.blur() also calls a AJAX function where I do a .post call to send in user modified data back to a URL (function in view).
The called function in view then commits the new changes in database and returns a 'success' event back to web page:
tc_model_instance.update(tc_id=json_data['id'])
Through this use case, as you can see the changes are immediately committed to the database as soon as user eneters data and gives up focus on a particular element. Without using DB transactions in INNODB, how do I go about creating a View-Template association such that any changes in HTML template are asynchronously reflected in the model, but not necessarily written into the database.
A related question:
If possible I'd also like to create a event based bi-directional association between rendered template and my data structures as part of the view in such a way that any changes made either in web browser's UI element or associated view's data are always in sync. I plan to use AJAX for the most purpose. Not sure if forms would make sense in this regard.
Thanks.
You could probably throw a copy of the object into the session map and all posts alter that object instead of the DB directly. Then when the user presses a save button you'd fire off another POST command to the server that would then just call session['my_object'].save().
Note though that the session object is also saved in the DB, so if you are trying to avoid hitting the DB totally what I wrote above wouldn't help.

Resources