输入文本区域有问题,因为如果我按回车键刷新页面,我就不想这样了。我阅读了很多教程和类似的问题,但对我来说没什么用。 我通过了我的angularjs代码:
$scope.startEditMode = function(className,index) {
$scope.editMode = true;
console.log($scope.editMode);
var td = document.getElementsByClassName(className);
var input = document.createElement("input");
input.type = "text";
input.value=td[index].innerHTML;
td[index].appendChild(input);
td[index].innerHTML='';
input.setAttribute("onSubmit","console.log('ciaaa')");
td[index].appendChild(input);
console.log(index);
}
当我在表格的单元格上单击两次以编辑其内容时,将调用此方法。
这是我的html表格代码:
<div class="tablewrap" id="display">
<div class="tablewrap-inner">
<div>
<table class="table table-hover" border="1">
<thead>
<tr>
<th class="check"><input type="checkbox" onchange="checkAll(this)" ng-click="checkAllTrue()"/></th>
<th class="descrPosHeader">Descrizione posizione <a ng-click="sort_by('name')"><i class="icon-sort"></i></a></th>
<th class="numPosHeader">Numero posizione <a ng-click="sort_by('numPos')"><i class="icon-sort"></i></a></th>
<th class="fattHeader">Fatturazione <a ng-click="sort_by('fatt')"><i class="icon-sort"></i></a></th>
<th class="impUnitHeader">Importo unitario <a ng-click="sort_by('impUnit')"><i class="icon-sort"></i></a></th>
<th class="quantHeader">Quantità unitaria <a ng-click="sort_by('quant')"><i class="icon-sort"></i></a></th>
<th class="impRataHeader">Importo rata <a ng-click="sort_by('impRata')"><i class="icon-sort"></i></a></th>
<th class="numRateHeader">Numero rate <a ng-click="sort_by('numRate')"><i class="icon-sort"></i></a></th>
</tr>
</thead>
<tbody>
<tr id="lista" ng-repeat="item in items | orderBy:sortingOrder:reverse ">
<td class="check"><input id="selectLine1" type="checkbox" value="{{item.check}}" ng-click="item.check=!item.check"/></td>
<td class="descrPos" ng-dblclick="startEditMode('descrPos',$index)">{{item.name}}</td>
<td class="numPos" ng-dblclick="startEditMode('numPos',$index)">{{item.numPos}}</td>
<td class="fatt" ng-dblclick="startEditMode('fatt',$index)">{{item.fatt}}</td>
<td class="impUnit" ng-dblclick="startEditMode('impUnit',$index)">{{item.impUnit | euro}}</td>
<td class="quant" ng-dblclick="startEditMode('quant',$index)">{{item.quant}}</td>
<td class="impRata" ng-dblclick="startEditMode('impRata',$index)">{{item.impRata | euro}}</td>
<td class="numRate" ng-dblclick="startEditMode('numRate',$index)">{{item.numRate}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
你有什么建议?