admin管理员组文章数量:1401158
What do I need to do in order to make the Kendo UI DropDownList display the title attribute as a kendoTooltip?
This is what I'm doing: /
<div class="editor-field">
<select id="Title" name="Title" title="What's your title?">
<option value="Mr.">Mr.</option>
<option value="Mrs.">Mrs.</option>
<option value="Miss">Miss</option>
</select>
</div>
$(function () {
var tooltip = $('#Title').kendoTooltip({
position: "right",
autoHide: true,
width: 280,
animation: {
open: {
effects: "slideIn:right",
duration: 300
},
close: {
effects: "slideIn:right",
reverse: true,
duration: 200
}
}
});
$("#Title").kendoDropDownList();
});
What do I need to do in order to make the Kendo UI DropDownList display the title attribute as a kendoTooltip?
This is what I'm doing: http://jsfiddle/EdsonF/qDRv3/1/
<div class="editor-field">
<select id="Title" name="Title" title="What's your title?">
<option value="Mr.">Mr.</option>
<option value="Mrs.">Mrs.</option>
<option value="Miss">Miss</option>
</select>
</div>
$(function () {
var tooltip = $('#Title').kendoTooltip({
position: "right",
autoHide: true,
width: 280,
animation: {
open: {
effects: "slideIn:right",
duration: 300
},
close: {
effects: "slideIn:right",
reverse: true,
duration: 200
}
}
});
$("#Title").kendoDropDownList();
});
Share
Improve this question
asked Nov 2, 2013 at 20:19
EdsonFEdsonF
2,8284 gold badges31 silver badges34 bronze badges
2 Answers
Reset to default 3The problem is that title
belong to the original select
but not to Kendo UI decorated element. When you convert a select
in a KendoUI DropDownList it creates some extra HTML elements around but title
is not copied into this element.
So, what you can do is:
// Create DropDownList
var title = $("#Title").kendoDropDownList().data("kendoDropDownList");
// Copy title from the select into the `wrapper` element
title.wrapper.attr("title", $("#Title").attr("title"));
// Now, define the tooltip for this wrapper element
var tooltip = title.wrapper.kendoTooltip({
position: "right",
autoHide: true,
width: 280,
animation: {
open: {
effects: "slideIn:right",
duration: 300
},
close: {
effects: "slideIn:right",
reverse: true,
duration: 200
}
}
});
The JSFiddle here: http://jsfiddle/OnaBai/qDRv3/4/
As it was previously mentioned, your original tag gets wrapped by Kendo UI and 'title' attribute is not copied over. It is relatively easy to fix by extending the DropDownList Kendo.UI class. Here is how I fixed it in my project (TypeScript):
export class DropDownListX extends kendo.ui.DropDownList {
// Constructor
constructor(element: Element, options?: kendo.ui.DropDownListOptions) {
super(element, options);
// Copy title attribute from element node to its parent (wrapper created by kendo ui)
$(element).parent().attr("title", $(element).attr("title"));
}
}
// Create an alias of the prototype (required by kendo.ui.plugin)
DropDownListX.fn = DropDownListX.prototype;
// Deep clone the widget default options
DropDownListX.fn.options = $.extend(true, { }, kendo.ui.DropDownList.fn.options);
// Specify the name of your Kendo UI widget. Used to create the corresponding jQuery plugin.
DropDownListX.fn.options.name = "DropDownListX";
// Create a jQuery plugin.
kendo.ui.plugin(DropDownListX);
本文标签:
版权声明:本文标题:javascript - Make Kendo UI DropDownList display the Title attribute of Select Control as a kendoTooltip - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744239619a2596725.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论