使用codeigniter在twitter bootstrap模式中填充表单

时间:2012-11-20 05:44:09

标签: php javascript codeigniter twitter-bootstrap modal-dialog

我正在使用Codeigniter框架和twitter bootstrap进行开发。在这里我遇到了一个问题,我必须在模态框中编辑一个表单。如何将数据传递到twitter bootstrap模式框中显示的表单?请帮我解决一个可能的解决方案。

1 个答案:

答案 0 :(得分:2)

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js">
</script>

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Header of Modal</h3>
  </div>
  <div class="modal-body">

    <form class="form-element">
        Title: <input type="text" class="form-title" value="initial title" /><br />
        Something Else: <input type="text" class="form-element2" value="initial value" /><br />
        <div class="some-box">
            The elements inside the box
        </div>
    </form>

  </div>
  <div class="modal-footer">
    <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Close</button>
  </div>
</div>

<a href="#" class="changeTitle">Click here to change title</a>
<a href="#" class="changeElement">Click here to change Element2</a>
<a href="#" class="changeDiv">Click here to change div's contents</a>

<script>
$(".changeTitle").click(function(){
    $(".form-title").val("New title");
});
$(".changeElement").click(function(){
    $(".form-element2").val("New value of element");
});
$(".changeDiv").click(function(){
    $(".some-box").html("New Contents of the div element");
});
</script>