为zendframework项目添加外部javascript库

Add external javascript library for Zendfreamework project

本文关键字:javascript 外部 添加 zendframework 项目      更新时间:2023-09-26

我想添加DataTable javascript库到我的Zendframe工作项目。所以有可能添加外部数据库到ZendFrame工作吗?我怎么能添加数据库到我的zend项目?

view.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>

我想使"示例"表预览为数据表我怎么能做到这一点?

只需将库和jQuery或任何其他所需的js库放在.e.g.中。Public/js然后在你的布局中。在php中(在head部分),您可以这样做:

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