1

我的插件使用 codeigniter 2.1 可以完美运行。我现在尝试将该插件用作由多个视图组成的动态生成页面的一部分。

为此,我的控制器包含以下内容:

$this->load->view('blue_view_widget'); // the file upload view
$this->load->view('form'); // a form

我现在看到模板上传和模板下载表(由 javascript 生成)被表单视图中的 html 覆盖。我在想(可能是错误的)第二个视图中的 html 在 javascript 有时间在视图底部动态生成表格之前就被回显了。我怎样才能解决这个问题 ?

这是我的代码:

</script>
<!-- The template to display files available for download -->
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<!--    <tr class="template-download fade">-->
    <tr class="template-download ">
        {% if (file.error) { %}
            <td></td>
            <td class="name"><span>{%=file.name%}</span></td>
            <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
            <td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td>
        {% } else { %}
            <td class="preview">{% if (file.thumbnail_url) { %}
                <a href="{%=file.url%}" title="{%=file.name%}" rel="gallery" download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a>
            {% } %}</td>
            <td class="name">
                <a href="{%=file.url%}" title="{%=file.name%}" rel="{%=file.thumbnail_url&&'gallery'%}" download="{%=file.name%}">{%=file.name%}</a>
            </td>
            <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
            <td colspan="2"></td>
        {% } %}
        <td class="delete">
            <button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
                <i class="icon-trash icon-white"></i>
                <span>{%=locale.fileupload.destroy%}</span>
            </button>
            <input type="checkbox" name="delete" value="1">
        </td>
    </tr>
{% } %}
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
<script src="blueimp/js/vendor/jquery.ui.widget.js"></script>
<!-- The Templates plugin is included to render the upload/download listings -->
<script src="http://blueimp.github.com/JavaScript-Templates/tmpl.min.js"></script>
<!-- The Load Image plugin is included for the preview images and image resizing functionality -->
<script src="http://blueimp.github.com/JavaScript-Load-Image/load-image.min.js"></script>
<!-- The Canvas to Blob plugin is included for image resizing functionality -->
<script src="http://blueimp.github.com/JavaScript-Canvas-to-Blob/canvas-to-blob.min.js"></script>
<!-- Bootstrap JS and Bootstrap Image Gallery are not required, but included for the demo -->
<script src="http://blueimp.github.com/cdn/js/bootstrap.min.js"></script>
<script src="http://blueimp.github.com/Bootstrap-Image-Gallery/js/bootstrap-image-gallery.min.js"></script>
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="blueimp/js/jquery.iframe-transport.js"></script>
<!-- The basic File Upload plugin -->
<script src="blueimp/js/jquery.fileupload.js"></script>
<!-- The File Upload file processing plugin -->
<script src="blueimp/js/jquery.fileupload-fp.js"></script>
<!-- The File Upload user interface plugin -->
<script src="blueimp/js/jquery.fileupload-ui.js"></script>
<!-- The localization script -->
<script src="blueimp/js/locale.js"></script>
<!-- The main application script -->
<script src="blueimp/js/main.js"></script>
<!-- The XDomainRequest Transport is included for cross-domain file deletion for IE8+ -->
<!--[if gte IE 8]><script src="js/cors/jquery.xdr-transport.js"></script><![endif]-->


THE SECOND VIEW ('FORM') BEGINS HERE.


 <div class="container">
         <base href="http://localhost/bootstrap1/">
<!--  <div class="row">-->
 <fieldset>

            <legend>Registration</legend>      


  <div class="span10" class="well">

        <form class="well" id="registerHere" method='post' action='index.php/site/process_form'>
//        



<div class="form_row" >

    <div class="control-group">  
            <label class="control-label" for="textarea">Textarea</label>  
            <div class="controls">  
              <textarea class="span8" class="input-xlarge" id="description" name="description" rel="popover" data-content="Re-enter your description." data-original-title="description" rows="3"></textarea>  
            </div>  
          </div>  
</div>    


<div class="form_row" >
4

1 回答 1

0

我没有想到“链接腐烂”。无论如何,以下是问题的答案:

我正在使用引导工具包,并试图在引导容器标签内创建自包含视图。我设置它的方式是:

标题

观点 A:HTML 在这里 css 和 js

视图 B:HTML 放在这里 css 和 js

页脚

当我连接 2 个视图时,我有一个重复的 jquery 脚本,在我的情况下导致 firebug 出现以下错误:

$(”#fileupload”).fileupload is not a function
[Break On This Error] 

$(’#fileupload’).fileupload();

鉴于我目前的 JS 技能不佳,我仍然不明白它的含义,但是一旦我注释掉第二个脚本,整个页面就开始按预期工作。

于 2012-08-11T13:35:38.957 回答