我有一个奇怪的麻烦,我使用backbone.js 创建了一个简单的视图:
class MyApp.Views.Tools.TextBox extends Backbone.View
template: JST['pdfs/tools/text_box']
tagName: "div"
className: "resizable"
id: "resizable"
events:
'click .close': 'closeRect'
initialize: ->
@
render: ->
$(@el).html(@template())
@initDraggable()
this
initDraggable: ->
$(@el).resizable().draggable();
#$(@el).css({"position": "absolute"})
@
closeRect: (event) =>
console.log "pass"
还有我的模板:
<div class="close">x</div>
<input type="text" name="text_' + @count++ + '" />
当我执行以下命令时:$(@el).resizable().draggable();,jQuery 将 style="position:relative" 添加到我的元素中。我知道为什么当我在 jQuery UI 上查看 Draggable 函数时:
if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
this.element[0].style.position = 'relative';
但我不明白为什么 this.element.css("position") 不返回我在元素上的 css 属性:position:absolute。
Backbone.js 是否可以在 css 之前加载 javascript 或者不使用我页面的 css?