5

我认为这是:

  <%--
  The training module list
  --%>
  <div id="training-mod-list-<%: categoryName.Replace(' ', '-') %>" class="training-module-list">
  <% foreach (var module in categoryGroup)
  { %>
    <div class="training-module-row">                                 
      <div class="training-module-name-<%: module.TrainingModuleId %>">    
          <script type="text/javascript">
             <%: Html.GetQTip(module.TrainingModuleId, "", "", QTipPosition.Right,true,""); %> //get error here it has some invalid arguments?
          </script> 
         <%: module.TrainingModuleName %>
      </div>
    </div>
 <% } %>

当我将鼠标悬停在每个培训模块名称上时,我希望显示一个 QTip。

然后获取Qtip:

 public static MvcHtmlString GetQTip(this HtmlHelper htmlHelper, string propertyName, string message, string propertyNameOverride = "", QTipPosition position = QTipPosition.Right, bool includeEvents = true, string title = "")
 {
  string qtipPosition = String.Empty;

  switch (position)
  {
    case QTipPosition.Right:
      qtipPosition = "my: 'left center', at: 'right center'";
      break;
    case QTipPosition.Left:
      qtipPosition = "my: 'right center', at: 'left center'";
      break;
    case QTipPosition.Top:
      qtipPosition = "my: 'top middle', at: 'bottom middle'";
      break;
    case QTipPosition.Bottom:
      qtipPosition = "my: 'bottom middle', at: 'top middle'";
      break;
  }

  if (!String.IsNullOrWhiteSpace(propertyNameOverride))
    propertyName = propertyNameOverride;

  if (String.IsNullOrWhiteSpace(title))
    title = htmlHelper.Resource(Resources.Global.Title.Information);

  StringBuilder sb = new StringBuilder();
  sb.Append(String.Concat("$('#", propertyName, "').removeData('qtip').qtip({content: {text:"));
  sb.Append(String.Concat("'", message, "', title: { text: '", title, "', button: false }}, position: { ", qtipPosition, " }"));
  if (includeEvents)
    sb.Append(", show: { event: 'focus mouseenter', solo: true, ready: false }, hide: 'blur'");
    sb.Append(", style: { classes: 'ui-tooltip-shadow ui-tooltip-yellow' } });");

    return new MvcHtmlString(sb.ToString());
  }
}

现在消息参数可以只是任何字符串有人可以向我解释它如何工作以显示每个培训模块ID的qtip吗?message 参数稍后将包含特定于每个训练模块 id 的点,这些点由 html 字符串组成

谢谢

4

1 回答 1

0

将 HTML 帮助程序的TrainingModuleId参数从 an转换int为 a String

<%: Html.GetQTip(module.TrainingModuleId.ToString(), "", "", QTipPosition.Right,true,""); %>
于 2014-05-15T18:25:40.387 回答