MVC3头jQueryMobile元素的JavaScript代码错误

时间:2012-06-29 08:22:44

标签: javascript asp.net-mvc-3

任何人都可以解决这个问题。我从ids和百分比的行动中得到两个数组我尝试所有编码,但没有成功但输出不正确

javascript代码

  @section javascript{
    <script type="text/javascript"> 
    $(document).ready(function() { 
        var percents = @Html.Raw(Json.Encode(ViewBag.percentage)); 
        var ids = @Html.Raw(Json.Encode(ViewBag.IDs)); 

        var date = new Date(); 
        var day = date.getDay(); 
        var dayper = (day / 30) * 100; 

        $.each(ids, function(index, id) { 
          var percent = parseInt(percents[index], 10); 
          var element = $('#' + id); 
          element.css('width', percent + '%'); 
          var rA = 100 - percent; 
          var color = 'green'; 

          if (rA - dayper > 40) { 
            color = 'red'; 
          } else if (rA - dayper > 20 && rA - dayper < 40) { 
            color = 'yellow'; 
          } 

          element.css('background-color', color); 
        }); 
    }); 
    </script> 


}

和jquerymobile代码用于实现类ui-bar divs

.....................  ............................

<div class="ui-bar-e" id="bdgt_@(item.budgetId)" >
 @Model.currency[l]@item.spentAmount/@Model.currency[l]@item.amount 
</div>

..........................................  ...............................

这里的错误是什么

从评论中修改

行动中:

string[] IDs = new string[bEList.Count]; 
int i = 0; 
foreach(var item in bEList) { 
   IDs[i] = "bdgt_" + item.budgetId; 
   i++; 
} 
ViewBag.IDs = IDs;

0 个答案:

没有答案