Welcome Guest, Not a member yet? Register   Sign In
where to put include jquery?
#11

[eluser]obay[/eluser]
i have tried checking out the library and i couldn't understand how it works lol! sorry im new to CI. anyways, i got everything working now by moving my includes folder to the same directory as system and using this:

< script type="text/javascript" src="<?= base_url() ?>include/jquery.js">< /script >

thanks all!! Smile
#12

[eluser]obay[/eluser]
can you guys help me use Phil's library? it looks great but i can't get it to work.

1. i downloaded the library. copied the files into their respective folders inside the application folder: config, helpers, libraries.

2. i moved my "assets" folder inside application. the path to my jquery is now /system/application/assets/js/jquery.js

3. added asset library into autoload.php:

Code:
$autoload['config'] = array('asset');
$autoload['libraries'] = array('asset');
$autoload['config'] = array('asset');

4. my view:

Code:
<?= js('jquery/jquery.js'); ?>
< script >
$(document).ready(function() {
     alert("hello");
});
< /script >

But it doesn't work. What am I doing wrong?

Any help appreciated Big Grin
#13

[eluser]Phil Sturgeon[/eluser]
[quote author="NateL" date="1252986202"]When you write a view, you will write something similar to this code:

Code:
&lt;link rel="stylesheet" href="&lt;?php echo site_url(); ?&gt;css/styles.css "type="text/css" media="screen" /&gt;
[/quote]

I don't mean to be picky but you have suggested a common mistake. This will break if you have index.php or any url_suffix. You should instead use base_url().

[quote author="obay" date="1253015565"]can you guys help me use Phil's library? it looks great but i can't get it to work.

1. i downloaded the library. copied the files into their respective folders inside the application folder: config, helpers, libraries.

2. i moved my "assets" folder inside application. the path to my jquery is now /system/application/assets/js/jquery.js

3. added asset library into autoload.php:

Code:
$autoload['config'] = array('asset');
$autoload['libraries'] = array('asset');
$autoload['config'] = array('asset');

4. my view:

Code:
&lt;?= js('jquery/jquery.js'); ?&gt;
&lt; script &gt;
$(document).ready(function() {
     alert("hello");
});
< /script >

But it doesn't work. What am I doing wrong?

Any help appreciated Big Grin[/quote]

Have you configured the config file? You can put the assets anywhere you like if you configure it nicely. Did you have a look at the README on the GitHub page?
#14

[eluser]obay[/eluser]
I read the README file but I didn't know what values to put in. I tried printing out the current default values and this is what i got:

Code:
$config['asset_dir'] = /documgt/C:\xampplite\htdocs\documgt/system/application/
$config['asset_url'] = http://localhost/documgt/

Is asset_dir even valid?

Can you help me figure out what values to put in there?

My assets folder is in

Code:
system/application/assets

Also, there is still an "index.php" when I open my pages, for example
Code:
http://localhost/documgt/index.php/document

I can also relocate my assets folder to my root, if you think that's a better idea.

Help? Smile
#15

[eluser]Phil Sturgeon[/eluser]
If your asset folder is in the web root you can do this:

Code:
/*
|--------------------------------------------------------------------------
| Asset Directory
|--------------------------------------------------------------------------
|
| Absolute path from the webroot to your CodeIgniter root. Typically this will be your APPPATH,
| WITH a trailing slash:
|
|    /assets/
|
*/

$config['asset_dir'] = '/assets/';

/*
|--------------------------------------------------------------------------
| Asset URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|    /assets/
|
*/

$config['asset_url'] = config_item('base_url').'/assets/;
#16

[eluser]obay[/eluser]
uber great!!! It works!!!! Thanks man!!!




Theme © iAndrew 2016 - Forum software by © MyBB