【问题标题】:Codeigniter - Grocery Crud doesn't load css and jquery?Codeigniter - Grocery Crud 不加载 css 和 jquery?
【发布时间】:2014-06-29 14:15:16
【问题描述】:

我正在使用 Codeigniter + Grocery Crud。 因此,GC 运行良好但为空白.. 显示来自数据库的结果,但未加载搜索选项和 css 样式。 我的结构是:

  • 应用

  • 资产

  • 系统

    GC 在资产内部。

我的控制器加载视图并将输出发送到视图:

public function output($output = null) {
    $this->load->view('welcome_message', $output);
}

public function users() {
    $this->load->library('grocery_CRUD');
    $this->output((object) array('output' => '', 'js_files' => array(), 'css_files' => array()));

    try {
        $crud = new grocery_CRUD();

        $crud->set_theme('flexigrid');
        $crud->set_table('suppliers');
         
        $output = $crud->render();
        
        $this->output($output);
    } catch (Exception $e) {
        show_error($e->getMessage() . ' --- ' . $e->getTraceAsString());
    }

}

之后,我使用 CG official tutorial 在视图中包含 jQuery 和 CSS 文件。他们在那里。当我点击(查看源代码)时 - 我可以看到它们。文件夹中没有问题。 我在查看源代码中看到了双 html 标签...是否存在任何 codeigniter 自动加载库来做到这一点?

我定义了自动加载助手 - url 和实用程序,这是我为加载资产文件夹而制作的。

我猜问题出在 ajax、jquery...但是如何解决呢?

【问题讨论】:

  • 您可以编辑帖子并为welcome_message.php 添加视图吗?看来您的问题是在视图中。
  • 你在控制器中写过 output() 函数吗?

标签: php jquery codeigniter grocery-crud


【解决方案1】:

Grocery CRUD 输出包含一个用于添加 java 脚本文件的数组

如果你想添加额外/自定义的 js 文件,那么你必须这样做:

$output = $crud->render();          
array_push($output->js_files, base_url("assets/my_js_folder/myjs.file.js")); 
array_push($output->js_files, base_url("assets/another_js/config.module.js")); 
$this->output($output);

我真的希望这对你有帮助:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-19
    • 2015-11-25
    相关资源
    最近更新 更多