Angular using ui router
If I load data from the srv with ajax, click on a link that change the state, and then go back to the previous link/state (by clicking back or a link) then the ajax data is lost from the $scope.
What is the correct way to store the data and avoid re running the ajax call?
Related
Based off of https://17.reactjs.org/docs/concurrent-mode-suspense.html it looks like it's best to put fetch requests in the side effect of the event, as opposed to the component itself.
So for example, instead of using useEffect inside a component to fire off a fetch request (let's say on mount "[]"), we place the fetch request directly inside the side effect of the button click event that would cause that component to be shown.
This makes sense for UIs that change on button clicks, but what about for components that are tied directly to the router system? If we add a side effect to an anchor tag that directs users to a page in our app, it works great. But what if the user uses the forward and back capabilities of the browser?
how can I do without reloading page load all data in react js?
I am creating treeview and in this node selected node value display in right-side view but refreshing page after showing the results.
For this i would be the best practice to user Redux in combination with SocketIO.
For a good example read this: Using socket.io in React-Redux app to handle real-time data.
I'm using backbone.js with react.js. I am using backbone routers to navigate.
Before navigating from one page to another page I'm creating a backbone event and passing some data through it. I'm listening to the same event in the next page. Till this point everything is fine. After that I'm moving from that page to other by using backbone routers only. But then I'm trying to go back with browser back button. Navigation working properly but data is not being displayed.
Hi I am trying to load states dynamically through an ajax request in the app.run() method.
In the same page, I have a link with ui-sref pointing to this dynamic state.
While loading the page, the ui-sref fires before this load and says state not found.
Any trick how we can overcome this?
Don't retrieve the states in app.run. Only bootstrap your app after the ajax request is returned.
I am building a shopping cart using backbone.js . When some one clicks on 'add to cart' I am making an ajax call using jQuery. Backend is rails. In response I get the new json value for the cart. However if I display the cart view then car view comes up , however the url does not change.
To make the url change I after receiving the response from jQuery I need to do something so that router catches the new url and things proceed from there.
How do I navigate to the #cart url?
You can update the URL by calling the navigate method on your router, like this:
router.navigate('cart');
Most likely your view doesn't have access to the router you can do this:
Backbone.history.navigate('cart', {trigger:true}); // router handles view change
Backbone.history.navigate('cart'); // only url is updated