Welcome Guest, Not a member yet? Register   Sign In
Solution for JS, AJAX, templating for CI

Someone has to take the rains on this topic... My proposed solution is to take some ideas from smartyCMS approach. by doing such we can keep js logic and CSS logic separate from php logic, and make everything JS framework independent.

my ideas would be, if ajax is to be used, simply make a MY_AJAX model that will be loaded to any control that may have ajax, so all Ajax logic and what ever lexicon created can be defind by the user there (or have a few already made for use with JSQuery dojo and so on) then create another directory structor for Views to be such like:

  | +AJAX.php [the logic funtions for ajax comunication]
  | +CSS.php [functions like css_define_id("#sidebar_clock",[widgetname]) os JS wrappers ]
    +-Assets/includes [common elements]
    | |-CSS
    | |-IMAGES
    | |-JS
    +-Widgets [templates to menubars/sidebars anything to plug in]
    +-Templates [each version of a site]
    | |
    | +Default_Name
    |  |-Assets  
    |  |-CSS
    |  |-JS

Example of a Controller:
class Customers extends Controller {

        function __construct() {

        function index()

              $CU_data = $this->db->get('customers');
              $curtime = getdate();
              $w_time['css'] = array(
                                                       'id' => 'currtime'
                                                       'name' = 'currtime' );
              $w_time['data'] = array(
                                                        'data' => getdate();
                                                        'title' => 'The current Date' );
             $data[widget_time] = $w_time;
             $data .= $CU_Data;

       function AJAX()
              $this->ajax->execute_action();  //logic for action or $this->[action]();

     function ADD()
               $this->db->insert('customers') = $this->ajax->data();
               $this->ajax->inerhtml_by_id('#status_message', '<B>ADDED</A>');

            } else {
               $this->db->insert('customers') = $this->posts;
               $data = array('message','Added');


Example of a Widget(filename: standard_dialogbox.widget)
<div id={$css[id]}>

Example of Template(filename: add.php):

{include: file='header.php'}
So this is my dialog box with a widget
{widget: 'standard_dialogbox.widget',$w_time}
{include: file='footer.php'}

extremely tired Will edit post with more examples, but i think this gives the direction

Messages In This Thread
Solution for JS, AJAX, templating for CI - by El Forum - 06-15-2010, 11:46 AM
Solution for JS, AJAX, templating for CI - by El Forum - 06-16-2010, 10:53 AM

Theme © iAndrew 2016 - Forum software by © MyBB