I am trying to get the values of a razor variable @item.name.It contains two names:name1 and name2.But when i use the following code i am getting only the first value ie,name1 in the javascript variable'nameVariable'
foreach (var item in CurrentPage.Children().Where("Visible"))
the div 'nameDiv' is repeating two times with the same value.I checked the values of @item.name ,it displays the two values but only first name is pushing into the 'nameVariable'.How can I get the solution??
access razor variable values in jQuery
hi,
I am trying to get the values of a razor variable @item.name.It contains two names:name1 and name2.But when i use the following code i am getting only the first value ie,name1 in the javascript variable'nameVariable'
foreach (var item in CurrentPage.Children().Where("Visible"))
{
@item.name
<script type="text/javascript"><!-- </p> <p><span style="white-space: pre;" mce_style="white-space: pre;"> </span></p> <p><span style="white-space: pre;" mce_style="white-space: pre;"> </span>$(".image").hover(function()</p> <p><span style="white-space: pre;" mce_style="white-space: pre;"> </span>{</p> <p><span style="white-space: pre;" mce_style="white-space: pre;"> </span>var nameVariable=$("name").html();</p> <p><span style="white-space: pre;" mce_style="white-space: pre;"> </span>$(".nameDiv").html(nameVariable);</p> <p><span style="white-space: pre;" mce_style="white-space: pre;"> </span>});</p> <p><span style="white-space: pre;" mce_style="white-space: pre;"> </span> // --></script>}
the div 'nameDiv' is repeating two times with the same value.I checked the values of @item.name ,it displays the two values but only first name is pushing into the 'nameVariable'.How can I get the solution??
Hi ,
Are you using a textString for the name1 and name 2 ? Or are you using the multiple textString from uComponents ?.
If so try doing something like this
@if(Item.HasValue("yourAlias") && Item.GetProperty("yourAlias").Value != String.Empty){foreach(var t in Item.yourAlias){
@t.InnerText <br />
}
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.