Sup*_*nja 5 php codeigniter twitter-bootstrap
我对Codeigniter很陌生,并且在我学习的过程中追求最佳实践.目前我有一个通过DB生成的表
HTML表格
<tr>
<td>
<a class="galName" href="#myModal" data-toggle="modal" >
<?php echo $gal['name']; ?>
</a>
</td>
<td>
<?php echo $gal['clientName']; ?>
</td>
</tr>
<?php endforeach; ?>
Run Code Online (Sandbox Code Playgroud)
模态
<div class="modal fade hide modal-creator" id="myModal" style="display: none;" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>Edit Gallery</h3>
</div>
<div class="modal-body"><?php echo form_open('url'); ?>
<div class="row">
<div class="span5">
<?php print_r($galleryName); ?>
<div class="control-group">
<?php
$galleryName = array(
'id' => 'galleryName',
'name' => 'galleryName',
'placeholder' => 'Gallery Name',
'required' => 'required',
);
echo form_label('Gallery Name:', 'galleryName');
echo form_input($galleryName);
?>
</div><!-- /control-group -->
</div><!--/span5-->
</div><!--/row-->
</div><!-- /modal-body -->
<div class="modal-footer">
<!-- <p class="span3 resize">The following images are sized incorrectly. Click to edit</p> -->
<a href="javascript:;" class="btn" data-dismiss="modal">Close</a>
<a href="javascript:;" class="btn btn-primary">Next</a>
</div>
Run Code Online (Sandbox Code Playgroud)
该链接调用一个bootstrap模式,我想在其中传递所选库的数据.我知道我可以通过jQuery传递数据,但是可以将这个模态保存在MVC框架中,如果是的话,如何通过模态链接调用控制器?
非常感谢您的帮助,并乐意接受有关CodeIgniter资源的任何建议.我目前正在使用Nettuts视频,虽然它们已经过时,但也在使用用户指南.
我真的认为你误解了模态是什么和控制器是什么,如果没有 ajax 调用,你就无法做到这一点: how does one go about calling the controller via the modal link
我通常做的是创建一个view/modals/文件夹,然后将所有引导模式放在那里,例如:
application/views/modals/my_modal_form.php\nRun Code Online (Sandbox Code Playgroud)\n\n这看起来就像你所展示的那样,里面:
\n\n<div class="modal fade hide modal-creator" id="myModal" style="display: none;" aria-hidden="true">\n <div class="modal-header">\n <button type="button" class="close" data-dismiss="modal">\xc3\x97</button>\n <h3>Edit Gallery</h3>\n </div>\n <div class="modal-body"><?php echo form_open(\'url\'); ?>\n\n <div class="row">\n <div class="span5">\n <?php print_r($galleryName); ?>\n <div class="control-group">\n <?php\n $galleryName = array(\n \'id\' => \'galleryName\',\n \'name\' => \'galleryName\',\n \'placeholder\' => \'Gallery Name\',\n \'required\' => \'required\',\n );\n echo form_label(\'Gallery Name:\', \'galleryName\');\n echo form_input($galleryName);\n ?>\n </div><!-- /control-group -->\n </div><!--/span5-->\n </div><!--/row-->\n</div><!-- /modal-body -->\n\n<div class="modal-footer">\n <!-- <p class="span3 resize">The following images are sized incorrectly. Click to edit</p> -->\n <a href="javascript:;" class="btn" data-dismiss="modal">Close</a>\n <a href="javascript:;" class="btn btn-primary">Next</a>\n</div>\nRun Code Online (Sandbox Code Playgroud)\n\n因此,当我需要该单一模式时,我只需将其加载到主控制器视图中,我想显示该模式,简单地执行以下操作:
\n\n <body>\n <?php echo $this->load->view(\'modals/my_modal_form\'); ?>\n\n <tr>\n <td>\n <a class="galName" href="#myModal" data-toggle="modal" >\n <?php echo $gal[\'name\']; ?>\n </a>\n </td>\n <td>\n <?php echo $gal[\'clientName\']; ?>\n </td>\n</tr>\n<?php endforeach; ?>\n </body>\nRun Code Online (Sandbox Code Playgroud)\n