Jquery 在引导框中提示如何增加文本区域的大小 bootbox.dialog({ 尺寸:大, 标题:“拒绝的原因?”, 关闭按钮:对, 信息: ' ' + ' ' + ' ', 类名:“中等”, 按钮:{ 取消:{ 标签:“取消”, 类名:“btn警告” }, 成功:{ 标签:“保存”, 类名:“btn成功”, 回调:函数(){ var result=document.getElementById('tarea').value; console.log(结果) 如果(结果){ 时间表\u arr=getTimesheet.split('\\s+'); 时间表={ 时间表\u arr:时间表\u arr, 状态:批准状态, 评论:结果 }; Timesheet=JSON.stringify(时间表); $.post($)http://localhost:8000/timer/approvetimesheet/“,{'Timesheet':Timesheet}, 函数(返回的数据){ 控制台日志(返回的数据); 如果(returnedData=='Set'){ 警报(“时间表被拒绝”); document.getElementById('accept')。disabled=true; document.getElementById('reject').disabled=true; } 如果(returnedData=='Own timesheet'){ 警报('您不能拒绝自己的时间表!'); } }); } } } } });
您可以使用以下代码: 第一种方法(使用内联CSS):Jquery 在引导框中提示如何增加文本区域的大小 bootbox.dialog({ 尺寸:大, 标题:“拒绝的原因?”, 关闭按钮:对, 信息: ' ' + ' ' + ' ', 类名:“中等”, 按钮:{ 取消:{ 标签:“取消”, 类名:“btn警告” }, 成功:{ 标签:“保存”, 类名:“btn成功”, 回调:函数(){ var result=document.getElementById('tarea').value; console.log(结果) 如果(结果){ 时间表\u arr=getTimesheet.split('\\s+'); 时间表={ 时间表\u arr:时间表\u arr, 状态:批准状态, 评论:结果 }; Timesheet=JSON.stringify(时间表); $.post($)http://localhost:8000/timer/approvetimesheet/“,{'Timesheet':Timesheet}, 函数(返回的数据){ 控制台日志(返回的数据); 如果(returnedData=='Set'){ 警报(“时间表被拒绝”); document.getElementById('accept')。disabled=true; document.getElementById('reject').disabled=true; } 如果(returnedData=='Own timesheet'){ 警报('您不能拒绝自己的时间表!'); } }); } } } } });,jquery,html,css,bootbox,Jquery,Html,Css,Bootbox,您可以使用以下代码: 第一种方法(使用内联CSS): bootbox.dialog({ size:large, title: 'Reasons for Rejection?', closeButton: true, message: '<div align="center"> ' + '<textarea cols="10" id="tarea" rows="10"></textarea> ' + '<
bootbox.dialog({
size:large,
title: 'Reasons for Rejection?',
closeButton: true,
message:
'<div align="center"> ' +
'<textarea cols="10" id="tarea" rows="10"></textarea> ' +
'</div> ',
className: "medium",
buttons: {
cancel: {
label: 'Cancel',
className: 'btn-warning'
},
success: {
label: "Save",
className: "btn-success",
callback: function () {
var result=document.getElementById('tarea').value;
console.log(result)
if (result) {
timesheet_arr = getTimesheet.split('\\s+');
Timesheet = {
timesheet_arr: timesheet_arr,
status: approval_status,
comments: result
};
Timesheet = JSON.stringify(Timesheet);
$.post('http://localhost:8000/timer/approvetimesheet/', {'Timesheet': Timesheet},
function (returnedData) {
console.log(returnedData);
if (returnedData == 'Set') {
alert('Timesheet was rejected');
document.getElementById('accept').disabled = true;
document.getElementById('reject').disabled = true;
}
if (returnedData == 'Own timesheet') {
alert('You cannot reject your own timesheet!');
}
});
}
}
}
}
});
您可以设置文本区域的宽度和高度。Bootbox实际上有一个选项,
inputType
,用于,您可以在其中指定备用输入类型,如图所示:
因此,您可以(在某种程度上)通过以下方式简化代码:
bootbox.prompt({
title: "This is a prompt with a textarea!",
inputType: 'textarea',
callback: function (result) {
console.log(result);
}
});
这个选项没有出现在最新的文档更新中(我的错),因此除非您真正查看源代码,否则它并不明显。针对
textarea
的id
,在您的例子中是它的#tarea
,并相应地设置它的高度宽度,并删除它的列
和`行属性OK,所以在css文件中我必须放置这些属性?高度和宽度?是的,在您的CSS文件中,例如:#tarea{width:300px;height:150px;}
您不应该鼓励任何人使用内嵌CSS。代码已更新。感谢@vivekkupadhayaglad的帮助:)错过了一个CSS示例。。。例如,设置文本区域的高度.medium textarea{height:300px;}
@LuckyEdward嗯,“medium”是OP正在使用的类,但是是的,这会起作用。这就是为什么我在示例中使用medium
。)
#tarea {
width: 300px;
height: 150px;
}
bootbox.prompt({
title: "This is a prompt with a textarea!",
inputType: 'textarea',
callback: function (result) {
console.log(result);
}
});
bootbox.prompt({
title: "Reasons for Rejection?",
className: 'medium',
// Change the input type
inputType: 'textarea',
// You can't change the buttons, but you can tweak their style and label (content)
buttons: {
cancel: {
className: 'btn-warning'
},
confirm: {
label: 'Save',
className: 'btn-success'
}
},
// Let Bootbox do the work of getting the textarea value
callback: function (result) {
// $.trim() isn't really necessary, but it
// prevents a user from simply hitting the spacebar and submitting
if ($.trim(result) != '') {
timesheet_arr = getTimesheet.split('\\s+');
Timesheet = {
timesheet_arr: timesheet_arr,
status: approval_status,
comments: result
};
Timesheet = JSON.stringify(Timesheet);
$.post('http://localhost:8000/timer/approvetimesheet/', {'Timesheet': Timesheet},
function (returnedData) {
if (returnedData == 'Set') {
alert('Timesheet was rejected');
document.getElementById('accept').disabled = true;
document.getElementById('reject').disabled = true;
}
if (returnedData == 'Own timesheet') {
alert('You cannot reject your own timesheet!');
}
});
}
}
});