dongqiu5184 2016-06-28 23:17
浏览 55

使用Codeigniter表库时将数据传递到Twitter Bootstrap Modal

I have a problem with my code.

I am currently loading my list of accounts through a database and generating a table with Codeigniters library, table.

$this->load->library('table');

$this->db->select('firstname, lastname, accountname, registerdate, birthdate, email');
$this->db->from('accounts');

$query = $this->db->get();

$template = array('table_open' => '<table class="table table-striped table-hover">');
$headings = array( 'Fornavn', 'Efternavn', 'Brugernavn', 'Registeringsdato', 'Fødselsdag', 'Email');
$this->table->set_template($template);
$this->table->set_heading($headings);

return $this->table->generate($query);

I would like a modal to open when clicking on the table row. My only headtwister is how I pass any data, like userid, to the modal opened? I can change the table template to open a modal but I cannot figure out how to pass the data. Since the data should be an id which changes from row to row, if you catch my drift.

I hope theres some smart brain out there who can help me!

Best regards OrKarstoft

  • 写回答

2条回答 默认 最新

  • duancaoqin6683 2016-06-29 00:38
    关注

    Initialize some id for 'table-open'. Then use jQuery on view side, when table is ready to insert attribute. Try this:

    //controller

    $template = array('table_open' => '<table class="table table-striped table-hover" id="myTable">');
    

    //view

    $(document).ready(function(){
        $("#myTable tr").each(function(index){
            $(this).attr('id', 'row_' + index);
        });
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝