我想创建一个树状结构,用户可以拖放树叶.我的起点如下:
HTML
<div ng:controller="controller">
<ul ui-sortable ng-model="items" ui-options="{connectWith: '.item'}" class="item">
<li ng-repeat="item in items" class="item">
{{ item.name }}
<ul ui-sortable ng-model="item.children" ui-options="{connectWith: '.item'}" class="item">
<li ng-repeat="item in item.children" class="item">{{ item.name }}</li>
</ul>
</li>
</ul>
<pre>{{ items | json }}</pre>
</div>
<script src="http://code.angularjs.org/1.0.2/angular.min.js"></script>
<script src="https://raw.github.com/angular-ui/angular-ui/master/build/angular-ui.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
CoffeeScript的
myapp = angular.module 'myapp', ['ui']
myapp.controller 'controller', ($scope) ->
$scope.items = [
{id: 1, name: 'Item 1', children: [
{id: 5, name: 'SubItem 1.1', children: [
{id: 11, name: 'SubItem 1.1.1', children: []},
{id: 12, …Run Code Online (Sandbox Code Playgroud) 我有以下代码,这些代码在Chrome,IE8和FF中非常有效。但是,当我用IE7测试它时出现错误。有人知道这里发生了什么吗?
function do_replace(s, p1,p2,p3,child_node,syn_text) {
reg = new RegExp('[h\|H][1-7]');
if(p1.length>0){ //this might not be necessary
//create textnode
var text_node = document.createTextNode(p1);
child_node.parentNode.insertBefore(text_node,child_node); //errors out here in IE7
}
Run Code Online (Sandbox Code Playgroud)
IE7的最后一行显示的代码错误为“ htmlfile:Invalid arguments”。通过调试器查看代码时发生错误。运行此脚本时,child_node,parentNode和text_node的构成与Firefox和Chrome相同。
有任何想法吗?还是IE7和其他浏览器一样不支持此方法?
谢谢