c# - 如何使用 Jquery Mobile 在 MVC 中动态创建带有 Count Bubbles 的链接

标签 c# jquery asp.net-mvc asp.net-mvc-4

非常需要你们的建议,已经在这上面浪费了两天了。不知道该怎么办。我需要使用 jquerymobile 来保持 mvc4 中按钮中的气泡计数。我是在静态中完成的,例如

代码。

<div class="ui-grid-c">
    <div class="ui-block-a">
        <a class="ui-li-has-count" data-role="button"  data-ajax="false" data-mini="true" style="background-color:#52616D;color:white" onclick="location.href='@Url.Action("Index", "DirectPutawayDetails")'">
           DK-01
           <span class="ui-li-count ui-btn-up-c ui-btn-corner-all" style="background-color:white;color:#52616D">
               3
           </span>
        </a>
    </div>
    <div class="ui-block-b">
        <a href="url.html" class="ui-li-has-count" data-role="button"  data-ajax="false" data-mini="true" style="background-color:#52616D;color:white">
            DK-02
            <span class="ui-li-count ui-btn-up-c ui-btn-corner-all" style="background-color:white;color:#52616D">
                11
            </span>
       </a>
   </div>
   <div class="ui-block-c">
       <a href="url.html" class="ui-li-has-count" data-role="button"  data-ajax="false" data-mini="true" style="background-color:#52616D;color:white">
           DK-03
           <span class="ui-li-count ui-btn-up-c ui-btn-corner-all" style="background-color:white;color:#52616D">12</span>
       </a>
  </div>
  <div class="ui-block-d">
      <a href="url.html" class="ui-li-has-count" data-role="button"  data-ajax="false" data-mini="true" style="background-color:#52616D;color:white">
          DK-04
          <span class="ui-li-count ui-btn-up-c ui-btn-corner-all" style="background-color:white;color:#52616D">
              145
          </span>
     </a>
</div>

效果很好,并且输出低于。

enter image description here

现在我需要动态生成所有按钮并带来类似的外观和感觉。我使用列表并将所有值带到我的 View 中,如下图所示。

但不知道如何将列表中的值转换为带有气泡计数的动态按钮。指导我。

enter image description here

最佳答案

https://dotnetfiddle.net/d0KH3g检查这个 fiddle

我创建了一个临时模型并根据模型值动态生成 DIV,尝试将其应用到您的模型中

@{
            string test ="";


            for(int i=0;i<@Model.countBubbleDataList.Count;i++)
            {
            string divTest="";

                divTest+="<div class='ui-block-a' style='width:25%'><a class='ui-li-has-count' data-role='button'  data-ajax='false' data-mini='true'";
                divTest+=" style='background-color:#52616D;color:white' onclick='location.href='@Url.Action('Index', 'DirectPutawayDetails')'>";
                divTest += Model.countBubbleDataList[i].Name+"<span class='ui-li-count ui-btn-up-c ui-btn-corner-all' style='background-color:white;color:#52616D'>3</span></a> </div></div>";

                    @Html.Raw(divTest);

    }

}

关于c# - 如何使用 Jquery Mobile 在 MVC 中动态创建带有 Count Bubbles 的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23951723/

相关文章:

c# - 如何使用 C# 有效地合并巨大的文件

c# - 在 C# 中使用时间跨度或表示时间跨度的整数值之间的区别

JQuery/MVC 搜索问题

c# - .net 处理异常的属性 - 在属性访问器上的使用

c# - ASP .NET MVC 如何使用@Html.EditorFor 增加输入字段的宽度

javascript - 如何将原型(prototype)的 $A() 函数转换为 jquery?

asp.net-mvc - 如何将 IStringLocalizer 注入(inject) IApplicationModelConvention?

c# - 一旦部署到网络服务器,MVC4 网络 API 找不到默认文档

javascript - 实时检测文本框中的内容?

javascript - 为什么 jquery 可能不会触发使用 AddClass 或 ToggleClass 添加的类的点击?