编辑时选择文本
问题描述:
我正在编辑Angularjs xeditable的一些用户。我希望在单击可编辑元素时选择文本。 我想我知道如何编写指令:编辑时选择文本
UserManager.directive('selectWhenEditing',function(){
var linkFunction = function(scope,element,attributes)
{
console.log(element.find('span'));
console.log(element.find('.editable'));
element.find('.editable').on('click',function(){
element.find('.editable-input').select();
console.log("launched");
});
};
return{
restrict: 'A',
link:linkFunction
};}
);
这是我的来电显示元素:
<td data-select-when-editing="">
<span class="ng-scope ng-binding editable editable-click" onbeforesave="checkUsername($data,user)" editable-text="user.username"> Name </span>
</td>
看来,find()方法没有找到类“编辑”(但它例如找到跨度)。虽然正如你可以在我的html代码中看到的那样,但可编辑类应用于跨度,因此它应该由find()找到。
谢谢你,但实际上这个问题不是指令,但它并没有得到我我想要的find方法... – Eagle1 2014-09-08 19:41:29