Welcome Guest, Not a member yet? Register   Sign In
javascript documentation
#1

[eluser]petroz[/eluser]
Guys... Im not getting anywhere with the javascript driver documentation. I dont know if Im just not getting it, or there is something missing.

Please clear up the following sections lacking in the documentation;

*How to initialize the javascript driver
*Configuring the javascript driver
*Adding custom javascript libraries
*Calling javascript functions (Where do they go? View, Controller?)
*Detail simple alert example
#2

[eluser]pickupman[/eluser]
I agree. It seems this was glossed over before the release. The documentation is incomplete and inaccurate. I have gotten this to work, but not in a way as shown. It appears the javascript library is stuck between being a library and a driver. The documentation shows it being a driver, but neither the code or folder structure is implemented in the way outlined in the documentation for drivers.

It seems the code started to be a jquery library, but decided to not work with jquery only. Now other js frameworks could be converted to being used which is a plus.

Items needed addressed in docs:
1. $script_foot is outputted not $script_head for views by default
2. drivers folder should be added with Jquery.php being in that folder, and Javascript folder should be added under /system with Javascript.php placed in it.
3. Syntax should be $this->load->driver('javascript');
4. jQuery is not a library as it is not in the /system/libraries folder and can not be loaded as such.
5. The configuration values are mentioned, but do not exists in application/config/config.php or in application/config/javascript.php. The latter would be nice to point to the lastest copy of jQuery from Google code cache
6. The document ready function should use something safer in case users are using two frameworks.
Code:
jQuery (document) . ready (function($){
//$ is protected for jQuery to use
});

Seems like a step in the right direction, however, so far the current implementation doesn't allow method chaining or other more advanced events you use with event bubbling.
#3

[eluser]pickupman[/eluser]
Here's a copy of a working example:
Code:
//Controller
        //Load jQuery from Google Code
        $this->config->set_item('javascript_location','http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js');
        
        $this->load->library('javascript');
        
        $output = array();
        
        //Add javascript events
        $output[] = $this->javascript->show('#details');
        $output[] = $this->javascript->hide('#fade-in');
        $output[] = $this->javascript->fadeIn('#fade-in', '5000');
        
        $this->javascript->output($output);
        $this->javascript->compile();

//View
<?php echo $library_src;?>
<?php echo $script_foot;?>
#4

[eluser]atno[/eluser]
[quote author="pickupman" date="1296966429"]Here's a copy of a working example:
Code:
//Controller
        //Load jQuery from Google Code
        $this->config->set_item('javascript_location','http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js');
        
        $this->load->library('javascript');
        
        $output = array();
        
        //Add javascript events
        $output[] = $this->javascript->show('#details');
        $output[] = $this->javascript->hide('#fade-in');
        $output[] = $this->javascript->fadeIn('#fade-in', '5000');
        
        $this->javascript->output($output);
        $this->javascript->compile();

//View
<?php echo $library_src;?>
<?php echo $script_foot;?>
[/quote]

thank you for the example i was like @#^(&U#(&U#Q! before reading it.
output() and compile() arent documented and im using the "live" user_guide
#5

[eluser]pickupman[/eluser]
Glad you got it working atno. I think the javascript library is in a weird state. The current documentation (2.0.2) is off. The library is supposed to be a driver so that it will work with other js frameworks. Right now it is still a library based on syntax.

I had a pull request for this [url="https://bitbucket.org/pickupman/codeigniter-reactor/changeset/5ea945c28a83"]here[/url] and [url="https://bitbucket.org/pickupman/codeigniter-reactor/changeset/8d7951761d26"]here[/url]on bitbucket, but it has been picked up yet.




Theme © iAndrew 2016 - Forum software by © MyBB