简体   繁体   English

为 Zendfreamework 项目添加外部 javascript 库

[英]Add external javascript library for Zendfreamework project

i want to add DataTable javascript lib to my Zendframe work project.So is that possible to add external data lib to ZendFrame work?我想将DataTable javascript 库添加到我的 Zendframe 工作项目中。那么可以将外部数据库添加到 ZendFrame 工作吗? and how can i add DataTable lib to my zend project?以及如何将 DataTable lib 添加到我的 zend 项目中?

view.phtml视图.phtml

   <script type="text/javascript">
    var baseUrl = "<?php echo $this->baseUrl(); ?>";
    $(document).ready(function(){
        $('.jbutton').button();
    });
    $(document).ready(function() {
        $('#example').dataTable();
    } );
</script>
<span id="edit-doctor" class="jbutton floatright marr5">
    <a href="<?php
echo $this->url(
        array(
    'controller' => 'patients',
    'action' => 'edit',
    'id' => $this->patientId
        ), 'default', true
);
?>">Edit Patient</a>
</span>
<div class="clear"></div>
<?php $user = $this->user; ?>
<h1 class="title"><?php echo $user['name']; ?></h1>
<div class="underling-green"></div>
<div class="profile">
    <div class="p-image">
        <img src="<?php echo $this->baseUrl() . '/images/users/' . $user['image']; ?>"/>
    </div>
    <div class="category mart50">
        <div class="sub-title">Personal Details</div>   
        <table>
            <tbody>
                <tr>
                    <td class="p-title">Email</td>
                    <td class="p-body">
                        <span class="p-seperate">:</span> 
                        <?php echo $user['email']; ?>
                    </td>
                </tr>
                <tr>
                    <td class="p-title">Birth Day</td>
                    <td class="p-body">
                        <span class="p-seperate">:</span>
                        <?php echo $user['bday']; ?>
                    </td>
                </tr>
                <tr>
                    <td class="p-title">Telephone</td>
                    <td class="p-body">
                        <span class="p-seperate">:</span>
                        <?php echo $user['telno']; ?>
                    </td>
                </tr>  
                <tr>
                    <td class="p-title">Address</td>
                    <td class="p-body">
                        <span class="p-seperate">:</span>
                        <?php echo $user['address']; ?>                       
                    </td>
                </tr>  
            </tbody>
        </table>      
        <table id="example">
            <thead>
                <tr>
                    <th>Column 1</th>
                    <th>Column 2</th>
                    <th>etc</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Row 1 Data 1</td>
                    <td>Row 1 Data 2</td>
                    <td>etc</td>
                </tr>
                <tr>
                    <td>Row 2 Data 1</td>
                    <td>Row 2 Data 2</td>
                    <td>etc</td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
<div class="clear"></div>

i want to make "example" table preview as DataTalbe how can i do it?我想将“示例”表预览作为 DataTalbe 我该怎么做?

Just put the lib and jQuery or any other required js libs in.eg public/js and then in your layout.phtml (in head section) you do as follows:只需将 lib 和 jQuery 或任何其他所需的 js 库放在 public/js 中,然后在您的 layout.phtml 中(在 head 部分),您可以执行以下操作:

$this->headScript()->prependFile($this->baseUrl('/js/jquery-version.js'));
$this->headScript()->appendFile($this->baseUrl('/js/datatableLib.js'));

echo $this->headScript();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM