spinner is not showing when data is loading in my home page. but showing in the register and login page.? - spinner

I have used spinner as a hook in react js. the spinner is working well in my login and register form. but when i implement this into my home page and when the data loading in my UI. the spinner does not show. i have tried it many way but not working. Give me a solution please.
i have put spinner in my home page in following way:
const [products] = useProducts()
const productsSliced = products.slice(0, 6)
{
productsSliced ? productsSliced.map(product => <Products key={product._id}
product={product} ></Products>) : <Spin></Spin>
}

Related

Return to Previous Url MVC 5

I started learning MVC and i am stuck in this problem.
I have an Order Details page in which I have a button "Edit". When the user clicks on it, opens up a Bootstrap Modal, which i called from a Partial View.
Now Modal opens up and shows the data, loaded from database and saves the data to database.
Everything is working just fine.
I just want the user to go back to that Specific Detail Page from where He/She clicked "Edit" Button.
For example
Detail Page URL is
../orders/details/2
form saves at
..order_detail/edit/[id]
after form submit it should go back to
../orders/details/2
How can i achieve this?
Any help would be much appreciated
Instead of returning on your current View after executing post method you can redirect to the action you want, passing the id. For example:
public ActionResult Edit(int id) {
...
return RedirectToAction("YourDetailsActionHere", new { id = id});
}
And if your action is in different controller you have to pass the controller name as well
return RedirectToAction("YourDetailsActionHere", "YourOtherController", new { id = id});

Chrome extension keeps resetting

I'm new to chrome extension development but I'm running into issues debugging and with the extension itself. I currently have a form with a submit button and after the user hits submit I change the html to show the data that was just submitted.
document.addEventListener('DOMContentLoaded', function() {
console.log("1");
document.getElementById("submitButton").addEventListener('click', myFunction);
console.log("2");
//getCurrentTabUrl(function(url) {
// renderStatus(url);
//});
});
function myFunction() {
document.getElementById("formOutput").innerHTML = document.getElementById("formInput").value;
alert("hi");
console.log("test");
);
}
In this, 1 and 2 are displayed to the extension debugging console and the alert runs as well when the button is clicked. The test shows up very briefly and then it disappears.The formoutput value changes very briefly as well and then changes back to the default value I have. Does anyone know why my code/the chrome extension would be doing this?
Thanks!
When button with type submit (This is the default if the attribute is not specified) is clicked, the form data will be sent to server and page will be redirected to new page. Then your content script will be injected again, that's why the it changes back to default value.
To avoid this, you could change button with other types, or calling e.preventDefault to prevent default behavior. Then you would want to use Ajax to send data to server, which ensure the whole page won't be redirected and only parts of UI can be updated.

JSF How to display the Navigation confirm popup before forwarding to other page

I'm using Primfaces Layout component in my pages and I'm not using Redirection in navigation when user clicks on the Menu links.
i.e.,I'm NOT using faces-redirect?true and URL doesn't change when user navigates.
I want to display a Confirmation Dialog before user navigates away from current view, like
“Are you sure you want to navigate away from this page?”
So once user clicks on the OK then it should forward to other page or else it should stay in same page if user clicks on CANCEL.
One more constraint is I want this functionality for only few selected pages not all of them.
What is the best approach to deal with this problem?
Primefaces Version: 3.5
JSF Version: 2.1.13
All my ManagedBeans are in #ViewScoped
If you want to try solving this problem from javascript-side, either go with
window.onbeforeunload = function(e) {
return 'Dialog text here.';
};
and see the dialog independent from the link being clicked (see https://stackoverflow.com/a/12132076/1269441). or try adding
onclick="if (!confirm('Your dialog-text here')) {return false;}"
to a selection of links you would like to have the dialog shown.

Boilerplate.js Programmatically navigate to a component

I have a component declared in a module and added as a route:
var controller = new Boiler.UrlController($(".appcontent"));
controller.addRoutes( {
'artists': new ArtistsComponent(context),
'clubs': new ClubsComponent(context)
});
controller.start();
I need to navigate to a component like 'clubs' programmatically. What is the exact syntax, please
You may see how this is done to navigate from list view to details view in the sample code in:
https://github.com/ectechno/boilerplatejs/blob/master/src/modules/sampleModule2/employeeList/viewmodel.js
The method call to navigate programmatically is:
Boiler.UrlController.goTo("artists");

UITabBarController tab to act as a Logout button instead of showing the corresponding view

I have a UITabBarController based iphone application. I added a new tab called Log Out via the Interface Builder.
However I don't need its corresponding view. I want the Log Out tab to redirect to the Login view as soon as it is clicked (of course some session clearing code is executed as well).
The nearest I've got so far is to redirect from the Log Out View using the viewWillAppear. The result is the same but it doesnt look great because it goes into a blank screen for a couple of seconds and then it redirect to the login screen.
Any help would be appreciated.
You can use UITabbarDelegate methods to accomplish this
Use following delegate method to check for logout buttons index and if found then perform your tasks
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
if (tabBarController.selectedIndex == 4)
{
// perform logout tasks
}
}

Resources