Reputation: 93
I want to shift focus to a div (#tab2) after a location.replace has called the function but I'm struggling to get it to work.
function deleteItem(parent) {
window.location.replace(pageContext +
'/delete/item/' +
$('#itemTabs').tabs( "option", "active" ) + '/' +
$('#accordion2').accordion( "option", "active" ) + '/' +
parent.find('.a-itemId').val());
}
This function deletes the item and once it has done so I need to redirect the page to a specific div rather than refresh the whole page. What would be the best method to get this to work?
Upvotes: 2
Views: 59
Reputation: 775
Try to use ajax. jQuery has a very easy to understand implementation of ajax. Visit this link for more information.
You can use it this way:
var url = pageContext +
'/delete/item/' +
$('#itemTabs').tabs( "option", "active" ) + '/' +
$('#accordion2').accordion( "option", "active" ) + '/' +
parent.find('.a-itemId').val();
$.ajax({
url: url,
success: function () {
// this function is called after your call has succeeded.
}
});
Upvotes: 1