du13932014807 2015-07-06 06:34
浏览 38

如何在/ user / settings html加载时添加js文件

I have a set of js files in the layout.phtml, but i dont need to load all the js files at once instead, i need to load on the individual pages. How can i do that.

<?php echo $this->headScript()
        ->appendFile($this->basePath() . '/js/jquery.js')
        ->appendFile($this->basePath() . '/js/jquery-1.9.1.min.js')
        ->appendFile($this->basePath() . '/js/jquery-ui.js')
        ->appendFile($this->basePath() . '/js/bootstrap.min.js')
        ->appendFile($this->basePath() . '/plugins/underscore/underscore-min.js')
        ->appendFile($this->basePath() . '/plugins/moment/moment.js')
        ->appendFile($this->basePath() . '/plugins/pace/pace.min.js')
        ->appendFile($this->basePath() . '/plugins/wysiwyg/bootstrap3-wysihtml5.all.min.js')
        ->appendFile($this->basePath() . '/plugins/validator/bootstrapValidator.min.js')

        ->appendFile($this->basePath() . '/plugins/clock-picker/clockpicker.js')

        ->appendFile($this->basePath() . '/plugins/bootstrap-calendar/js/calendar.js')
        ->appendFile($this->basePath() . '/plugins/Chart.js-master/Chart.js')
        ->appendFile($this->basePath() . '/js/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9',))
        ->appendFile($this->basePath() . '/js/html5shiv.js',   'text/javascript', array('conditional' => 'lt IE 9',))

        ->appendFile($this->basePath() . '/js/main.js')
        ->appendFile($this->basePath() . '/js/profile.js')
        ->appendFile($this->basePath() . '/js/profile_12.js')
        ->appendFile($this->basePath() . '/js/profile_2.js')
        ->appendFile($this->basePath() . '/js/profile_users_medical_events.js')

        ->appendFile($this->basePath() . '/plugins/cropper/cropper.min.js')
        ->appendFile($this->basePath() . '/js/profile-photo.js')
        ->appendFile($this->basePath() . '/js/select2.min.js')
        ->appendFile($this->basePath() . '/js/selectize.min.js')
        ->appendFile($this->basePath() . '/js/new_appointment.js')
        ->appendFile($this->basePath() . '/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.js')
        ->appendFile($this->basePath() . '/js/users_profile_chart.js')
        ->appendFile($this->basePath() . '/js/livestamp.min.js')
        ->appendFile($this->basePath() . '/js/res.js')

        ->appendFile($this->basePath() . '/js/rec.js')
        ->appendFile($this->basePath() . '/js/settings.js')

     ; ?>

What i need is load only the needed js file .

  • 写回答

1条回答 默认 最新

  • doushichi3678 2015-07-06 11:55
    关注

    Like you did it in layout - you can call the helper in your view.

    <?php $this->headScript()->appendFile($this->basePath() . 'my.js') ?>
    
    <h2>Some Heading</h2>
    

    But don't echo it - it will be appended to that list in your layout and is placed there.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看