2016-06-22 18 views
1

我想用按钮内联x可编辑。 同样喜欢这个样本 http://jsfiddle.net/jjdJX/3/内联可编辑按钮和动态元素

,如果我用这个与修复选择像

$('#publicname-change').editable({ 

工作正常。

但我有元素和那里的ID,他们来自数据库......我不能说我有多少ID和有什么名称。 我现在使用一个按钮。如果我点击这个按钮(就像在这个例子中),那么我也从这个字段得到我需要的id。

如果可能的话我可以用$( '#' + myselectorId).editable({

如果DOM负载OK,然后我可以找到所有有ID的

如果我上的按钮KLICK然后我可以从编辑的字段是什么,我需要得到的ID。

正常,我必须解决像选择

$('#username').editable({ 
    type: 'text', 
    pk: 1, 
    url: '/post', 
    title: 'Enter username' 
    }); 

我正在寻找一种方式通过点击该按钮来调用这个编辑nd与这样的动态id(选择器)

$('#'+myselectorId).editable({ 
type: 'text', 
pk: 1, 
url: '/post', 
title: 'Enter username' 

});

对不起,我的英语..

问候 克林斯曼

回答

0

可以工作,因为你看输入:

var inputObj=[]; 
$("input").each(function(index){ 
    thisID=$(this).attr("id"); 
    thisNAME=$(this).attr("name"); 
    inputObj[index]={"thisID":thisID,"thisNAME":thisNAME}; 
    console.log("thisID: "+thisID+", thisNAME: "+thisNAME); 
}); 

var inputTotal=""; 
for(i=0;i<inputObj.length;i++){ 
    inputTotal += JSON.stringify(inputObj[i]); 
} 
console.log(inputTotal); 

它运行在您的所有网页。
Console.log可能已足够。

它给这种结果: enter image description here

其他很酷的事情是这样的sotfware:Agent Ransack完全免费,真正有用的关键词的文件名称和文件中大的web开发文件夹小号搜索内容+正则表达式。

必须!

;)

0

首先,感谢您的帮助和回答。

也许我先介绍这个问题没有正确的...

我想在我的测试webside使用jQuery X编辑插件工作.... 工作这个插件罚款......但现在我加载活力的一面......他们包括一些标签...标签的数量都取决于标签有多少是在数据库中...

我希望的代码使之成为更加清楚一点理解....

 <?php 


    echo '<ul class="nav nav-tabs navSub">'; 
    while($row  = mysqli_fetch_object($result_4)){ 
    $active = ""; 
    if ($row->active ==1){ 
     $active = "active"; 
    } 
    echo '<li class="'.$active.'" id="'.$row->liBoxId.'" 
    typeGroup="'.$row->typeGroupId.'">'; 
    echo '<a href="#"'.$row->divBoxId.'" class="editable shortDesc" name="shortDesc" id="'.$row->editableid.'" onclick="request(7,1,1, 1, 0,0, '.$row->typeGroupId.')" data-toggle="tab">'; 
     echo ''.$row->tabTitle.''; 
      echo '<span class="badge badge-success">&nbsp;</span>'; 
     echo '</a>'; 
    echo '</li>'; 
}; 

     echo '<button type="button" id="editTitle" class="btn btn-white btn-info">'; 
     echo '<i class="blue ace-icon fa fa-pencil center bigger-110"></i>'; 
     echo '</button>'; 
     echo '</ul>'; 

     ?> 

    <script> 

      $(document).ready(function() { 
      $('.shortDesc').each(function() { 
      $('#'+this.id+'').editable('disable', true); 
      }); 
     }); 



      jQuery(function($) { 

      $.fn.editable.defaults.mode = 'inline'; 
      $.fn.editableform.loading = "<div class='editableform-loading'><i class='ace-icon fa fa-spinner fa-spin fa-2x light-blue'></i></div>"; 
      $.fn.editableform.buttons = '<button type="submit" class="btn btn-info editable-submit"><i class="ace-icon fa fa-check"></i></button>'+ 
             '<button type="button" class="btn editable-cancel"><i class="ace-icon fa fa-times"></i></button>'; 



     } 

      $('#editTitle').click(function(e){ 
       var id = $("ul.navSub li.active").attr('id');    
       id = "editable-"+id; 
       e.stopPropagation(); 
       $('#'+id+'').editable('enable', true); 
       //$('#publicname-change').editable('toggle'); 
     }, 
     $('#'+id+'') 
      .editable({ 
       type: 'text', 
       name: 'shortDesc', 
       data: {oper:'editDetail'}, 
       url: 'incl/asedScripts/ased_updateTitle.php', 
       success: function(data,response, newValue) { 
        if(response.status == 'error') return response.msg; 

       } 
     });  
    ); 
    </script> 

我不知道是否有可能在可编辑它们,我从一个jQuery呼叫拿到ID ....任何帮助

$('#'+id+'') 
      .editable({ 

最诚挚的问候和感谢

克林斯曼