我正在尝试使用html5(contenteditable ="true")和jquery创建一个可编辑的框(类型为richTextBox).我需要找到可编辑div中每个元素的位置,以便我可以像微软一样插入分页符.这是页面
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Context Menu Plugin Demo</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script src="http://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready( function() {
$("#divEdit").keyup(function(){
$.each($("#divEdit").find("*"), function(i,item){
alert(item.position());
});
});
});
</script>
</head>
<body>
<h1>jQuery Context Menu Plugin and KendoUI Demo</h1>
<div style="width:740px;height:440px" contenteditable="true" id = "divEdit">
<p>
<img src="http://www.kendoui.com/Image/kendo-logo.png" alt="Editor for ASP.NET MVC logo" style="display:block;margin-left:auto;margin-right:auto;" />
</p>
<p>
Kendo UI Editor allows your users to edit HTML in a familiar, user-friendly way.<br />
In this version, the Editor provides the core …Run Code Online (Sandbox Code Playgroud) 我写了一些代码来生成自定义控件.代码返回一个jQuery元素,调用者将此jQuery元素附加到DOM.我将自定义滚动条应用于生成器代码中的控件,但它未应用,因为该元素尚未附加到DOM.
我的问题:是否有任何onAppend事件或类似事件,以便我在元素附加到DOM时应用自定义滚动条?
生成器的示例代码:
function getControl(controlParams){
var $control = $('<div/>');
$control.applyCustomScrollBar(); //Not appended to DOM yet, so doesnt work
return $control;
}
Run Code Online (Sandbox Code Playgroud)
消费者的示例代码:
var $control = getControl(controlParams);
$("body").append($control); //Appending to DOM now
Run Code Online (Sandbox Code Playgroud)
想做类似的事情:
function getControl(controlParams){
var $control = $('<div/>');
$control.onAppend(function(){
$(this).applyCustomScrollBar();
});
return $control;
}
Run Code Online (Sandbox Code Playgroud) 我试图在这样的模型中渲染一个jbuilder部分:
class Reminder < ActiveRecord::Base
...
def fcm_format
Jbuilder.new do |json|
json.partial! 'api/v1/gigs/summary', gig: remindable
end
end
end
Run Code Online (Sandbox Code Playgroud)
但这给了我以下错误。
TypeError:{:gig =>#}既不是符号也不是字符串
有没有办法渲染模型或装饰器的局部内部?