关于编辑如何使用来自<a> tag

时间:2019-04-04 05:32:31

标签: javascript bootstrap-4 x-editable

I am rendering around 100+ fields after loading data from DB, my intention is to show these fields as normal editable text fields with data in them. But when user clicks on any of these fields, An x-editable popup should appear and that it should have the text field's value pre-filled in it (so that user dont have to type everything).

Here is html code:

<a href="#" data-type="text" id="abn" data-pk="1" data-url="/post" data-title="Enter ABN">
 <input type="text" id="abn" name="abn" class="form-control" value="<?php echo $drvData->ABN; ?>" >
</a>

in JS i m just doing this:

$.fn.editable.defaults.mode = 'popup';
$('#abn').editable();

But the problem is that if i set x-editable attribute "data-value" it will show like a href not like a text field. but if I use

<input type="text" value="<?php echo $drvData->ABN;?>" ...> 

it shows popup as empty, anybody can pls help me, i think it has something to do with .editable() to pass the value on but not sure how to do it.

1 个答案:

答案 0 :(得分:0)

我不确定这是否是解决问题的正确方法,但它对我来说是否完美:

在标签中而不是使用我已经使用并完成了以下操作:

<a href="#" data-type="text" id="ABN" data-pk="1" data-url="/post" data-placement="right" data-title="Enter ABN">
<textarea id="abn" name="abn" class="form-control" >
<?php echo $drvData->ABN; ?>
</textarea>
</a>

在CSS中,我这样做是为了将文本区域显示为输入字段:

<style> textarea {  height: 38px;  resize: none;} </style> 

仅供参考:$.fn.editable.defaults.mode = 'popup';

我做了很多搜索,但是除了这种解决方法之外,找不到任何可以在锚标记中嵌入输入字段的东西,我不得不使其工作,所以我这样做了:)