How to add a tooltip based on a DropDown list with Kendo wrappers?

家住魔仙堡 提交于 2019-12-11 09:33:03

问题


DropDownList:

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

ToolTip

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

The content "Hello" I want it to base it on the item selected on ddlRoles


回答1:


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

Then the Tooltip

  @(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;
}


来源:https://stackoverflow.com/questions/29288874/how-to-add-a-tooltip-based-on-a-dropdown-list-with-kendo-wrappers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!