Hi,
I've got a bug in my sitye where I am passing the current page Id to the indexer. The reason I'm doing this is so I return only the blogs from a specific site. I'm hosting 2 sites on one instance of Umbraco.
On the initial load the correct blogs are shown and all is good, however, when I call this method via ajax I get an error.
umbracoHelper.AssignedContentItem.Id = 'umbracoHelper.AssignedContentItem.Id' threw an exception of type 'System.InvalidOperationException'
I'm presuming this is because it's an ajax call but I can't figure out how to get this working.
Ajax requests don't generally have an assigned content item on the Umbraco helper. You are better off passing the key of the page as part of the request.
Is there a way to have a fallback so if Umbraco.AssignedContentItem.id isn't valid due to it being a ajax request then use Model.CurrentPageId?
Reason I ask is, on initial page load, Umbraco.AssignedContentItem.Id works. This means I can then take the id and post it via a model and ajax to my pagination method.
But then when the pagination loads the page, Umbraco.AssignedContentItem.Id throws an error because it's not got a value but now Model.CurrentPageId does.
Pagination not working via Ajax call
Hi, I've got a bug in my sitye where I am passing the current page Id to the indexer. The reason I'm doing this is so I return only the blogs from a specific site. I'm hosting 2 sites on one instance of Umbraco.
On the initial load the correct blogs are shown and all is good, however, when I call this method via ajax I get an error.
umbracoHelper.AssignedContentItem.Id = 'umbracoHelper.AssignedContentItem.Id' threw an exception of type 'System.InvalidOperationException'
I'm presuming this is because it's an ajax call but I can't figure out how to get this working.
Ajax requests don't generally have an assigned content item on the Umbraco helper. You are better off passing the key of the page as part of the request.
A great, of course! Thanks.
Now passing the value from
@Umbaco.AssignedContentItem.Id
to my javascript which then passes the value to my controller.Cheers! O.
Is there a way to have a fallback so if
Umbraco.AssignedContentItem.id
isn't valid due to it being a ajax request then useModel.CurrentPageId
?Reason I ask is, on initial page load,
Umbraco.AssignedContentItem.Id
works. This means I can then take theid
and post it via a model and ajax to my pagination method.But then when the pagination loads the page,
Umbraco.AssignedContentItem.Id
throws an error because it's not got a value but nowModel.CurrentPageId
does.Changed my approach and it now works.
Just had to walk away from the screen and get some food.
I'll blog about how I fixed the issue.
is working on a reply...