当选择href时,在小提琴下面尝试触发带有截断文本的对话框:
<a href='javascript:void(0)' id="truncatedText" onclick='fnOpenNormalDialog("this is the text to truncate");return false'></a>
$(function(){
$("#truncatedText").text(truncateText('truncate this text'));
})
function truncateText(text) {
var shortText = jQuery.trim(text).substring(0, 20) .split(" ").slice(0, -1).join(" ") + "...";
console.log(shortText)
return shortText
}
function fnOpenNormalDialog(text) {
$("#dialog-confirm").html("Confirm Dialog Box");
// Define the Dialog and its properties.
$("#dialog-confirm").dialog({
resizable: false,
modal: true,
title: "Modal",
height: 250,
width: 400,
buttons: {
"Yes": function () {
$(this).dialog('close');
callback(true);
},
"No": function () {
$(this).dialog('close');
callback(false);
}
}
});
}
jsfiddle:http://jsfiddle.net/vvjj8/6236/
但找不到函数fnOpenNormalDialog
,Chrome错误:
Uncaught ReferenceError: fnOpenNormalDialog is not defined(index):72 onclick
功能是否未正确定义?
答案 0 :(得分:0)
我已经更新了你的jsfiddle,并添加了缺少的div。
您的链接现在看起来像这样
<a href='#' id="truncatedText"></a>
<div id='dialog-confirm'></div>