如何添加基于与剑道包装下拉列表中的提示?(How to add a tooltip based on

2019-10-22 10:04发布

下拉列表:

 @(Html.Kendo().DropDownList()
                              .Name("ddlRoles")
                              .OptionLabel("ACCOUNT TYPE")
                              .HtmlAttributes(new { @class = "ddlRoles" })
                              .BindTo((IEnumerable<SelectListItem>)ViewBag.ApplicationRoles)
                          )

工具提示

 @(Html.Kendo().Tooltip()
                        .For("#help-tooltip")
                        .Position(TooltipPosition.Top)
                        .Content("Hello")  
                        )

内容为“你好”我希望它作为它的基础上ddlRoles选择的项目

Answer 1:

   @(Html.Kendo().DropDownList()
                                  .Name("ddlRoles")
                                  .OptionLabel("ACCOUNT TYPE")
                                  .HtmlAttributes(new { @class = "ddlRoles text-danger" })
                                  .BindTo((IEnumerable<SelectListItem>)ViewBag.ApplicationRoles)
                                 )
                              )

然后,工具提示

  @(Html.Kendo().Tooltip()
                            .For("#ddlRoles").

                            .Position(TooltipPosition.Top)
                            .Events(events => events.Show("onHoverShowToolTip"))
                            )

when the tooltip is shown, call a javascript function

    function onHoverShowToolTip() {
        loadToolTipContent();
    }

function loadToolTipContent() {
    //this call getToolTipContent();
    $("#the name of the generated tooptip").data("kendoTooltip").options.content = getToolTipContent();

    $("#the name of the generated tooptip").data("kendoTooltip").refresh();
}

function getToolTipContent() {
    var role = selectedRole();
    var result = "THE CONTENT THAT YOU WANT";

    return result;
}


文章来源: How to add a tooltip based on a DropDown list with Kendo wrappers?