Hi, I have jquery code that is being reused by a repeatable partial view on an asp.net mvc page but the script is not executing as I expect it should.
The scenario is not that complex, I have a page with multiple reviews for an item, and users who are logged in are allowed to 'vote up' or 'vote down' a review via a thumbs up/thumbs down button (similar to digg).
I have each scenario's text rendered inside a <span>
where the id='spanname-'+reviewId so each review's rating is uniquely identifiable (since they are repeatable since multiple reviews exist on the page, each with the same functionality) so e.g. if I want to ask the user to log in if they are not currently, I have the following html
<span id="login-<%=Model.EntityId%>" style="margin: 0 5px 0 5px;display:none;">
Why not <a href="#">login</a> and rate this?
</span>
and appropriate an initialise() method which sets
var isAuthenticated = <%=Request.IsAuthenticated.ToString().ToLower() %>;
function initialise()
{
if (isAuthenticated)
{//hide login spans, unhide other spans}
else
{
//alert('user not logged in')
$('rate-<%=Model.EntityId%>').hide();
$('login-<%=((GigItModel)Model).EntityId%>').show();
//alert($('login-<%=((GigItModel)Model).EntityId%>'));
}
}
$().ready(function()
{
initialise();
});
I've put alert buttons to test that it detects a logged in user vs a non-logged in user and also that it is referencing objects but for some reason the page is not rendering the CSS attributes and is showing NONE of the <span>
's (or all if i remove the display:none in the style
attributes)
Can anyone offer insight as to why the jquery is not executing as expected? Thanks in advance.