jQuery in CodeIgniter, inside the view or in external js file?

前端 未结 3 1328
野的像风
野的像风 2020-12-29 13:13

I\'m developing web application using CodeIgniter. All this time, I put the custom js code to do fancy stuffs inside the view file. By doing this, I can use site_url()

3条回答
  •  臣服心动
    2020-12-29 13:45

    I typically keep mine in an external file, but place a single line within my template (view) that declares a javascript variable called "baseurl" that can later be used by my external javascript.

    
    
    

    Now my scripts.js file has access to the base_url() value via its own baseurl variable.

提交回复
热议问题