2015-10-22 20 views
0

我想给用户增加/编辑url的灵活性,使用引导可编辑的图像来添加/编辑网页,这通常用于内联文本编辑。我在锚点标签之间添加了一个图片标签,这非常适用,除了当用户添加链接时,图片变得隐藏/不可见。当页面刷新时,图像重新出现并且链接保存在后端。我注意到编辑后,Html代码中的图像标签不存在。当使用Bootstrap添加链接时,图像标记消失编辑

我想知道我在这里错过了什么。代码:

 <HTML>  

     <div class="col-xs-6 col-md-3"> 
     <a href="{{user.facebook}}" id="linkedin" data-type="text" data-url="{{ url_for('account.AccountView:editFacebook') }}" data-pk="{{user.id}}" data-title="Change your Facebook profile url" ><img id="facebooklogo" width="200" height = "70" class="img img-rounded" src="/static/logos/facebook.jpg"></img></a>        
     </div> 

     <Jquery> 

     <link href="/static/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/> 

     $('#facebook').editable({ 
     placement:"right", 
     error: function (errors) { 
     } 

     }); 

     <script src="/static/bootstrap3-editable/js/bootstrap-editable.min.js"></script> 

回答

0

我得到了答案。所有人需要添加此代码:

 $('#facebook').editable({ 
     placement:"right", 
     error: function (errors) { 
     }, 
     display: function(value, response) { 
     $(this).html('<img src="logos/facebooklogo.jpg">'); 
     } 

     }); 

     instead of just 

     $('#facebook').editable({ 
     placement:"right", 
     error: function (errors) { 
     } 

     }); 

它工作。