Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    •  
      CommentAuthorbigtalk
     

    I read in Ruby on Rails that there is a .rjs file that lives in the views folder where one defines the javascript effect for one's ajax.
    How do I define the effect in Akelos?
    This is what I have:

    In my controller I have

    class PageController extends ApplicationController
    {
    
        var $models = array('news', 'tracks');
    
        function index()
        {
        }
    
        function show_about()
        {
            $this->renderPartial("about.tpl");
        }
    

    In my view I have

       <%= link_to_remote "about", :url => { :action => :show_about }, :update => "content" %>  
       <div id="content"></div>  
    

    In my _about.tpl partial I have

       <div class="box">
          <p>Lots of text and stuff in here.</p>
       </div>
    

    In my layout I have

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
          <title><?php  echo $text_helper->translate('Scalfati.com',array(),'layout');?>: <?php  echo $text_helper->translate($controller->getActionName(),array(),'layout');?></title>
          <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
          <?php  echo  $asset_tag_helper->stylesheet_link_tag('scaffold', 'scal.css') ?>
        </head>
        <body>
    
         {?flash-notice}<div class="flash_notice">{flash-notice}</div>{end}
    
        <div id="distance"></div>
        <div id="wrapper">
          <%= javascript_include_tag 'prototype' %>
          <%= javascript_include_tag 'scriptaculous' %>
          <%= javascript_include_tag 'unittest' %>
          <?php  echo  $content_for_layout ?>
        </div>
    
        </body>
      </html>
    

    Before I started with Akelos I used

      <a href="#" onclick="Effect.toggle('about','appear'); return false;">about</a>
    

    where 'appear' is the effect I want.

    Sorry for such a "codey" post. Trying to be as communicative as possible.
    I really do appreciate all the help you veterans give us noobies here in the forum. Perhaps someday I'll be versed enough to help someone myself!

    •  
      CommentAuthorbigtalk
     

    I was digging around in the API and I got the bright idea to look for "PrototypeHelper". (I don't know if I said this, I'm really new to all this. API hasn't really been part of my vocabulary.) There I found the "link_to_remote" method.
    I looked further and found the ScriptaculousHelper. This helper has the visual_effect method. Here's the example given:

      <?= $prototype_helper->link_to_remote( 'Reload', 'update' => 'posts', 'url' => array('action' => 'reload'), 'complete' => $scriptaculous_helper->visual_effect('highlight', 'posts', array('duration' => 0.5))) ?>  
    

    I tried to adjust my code in my view. I obviously have been getting it wrong. Here's the error:

     Parse error: syntax error, unexpected T_DOUBLE_ARROW in /tmp/views/app/views/page/compiled/view.tpl.php on line 1  
    

    The example above is what is on line 1.
    I'm going to keep diggin around and studying and posting what i figure. If help comes along, all th better!

    Cheers!

    • CommentAuthorliyh
     
    can you tell me how to add "Jquery" with helper? thank you.
    •  
      CommentAuthorbigtalk
     

    I believe that Akelos is currently designed with Scriptaculous in mind. I've seen some posts talking about implementing the MooTools library. To use Jquery, you would probably have to write a JqueryHelper similar to the PrototypeHelper and the ScriptaculousHelper (both of which extend AkActionViewHelper).
    I'm not too hip to Jquery and pretty much a noob as far as all of this is concerned, so don't come down on me if I'm wrong.
    Anyone confirm this?

    • CommentAuthorKaste
     

    hm, that was

    copy jquery.js to /public/javascripts/

    and put

    <%= javascript_include_tag 'jquery' %>
    <? echo $asset_tag_helper->javascript_include_tag ("jquery"); ?>
    

    in the view/layout. now you should have at least jQuery loaded.

    •  
      CommentAuthorbigtalk
     

    OK. So I know why i was getting

      Parse error: syntax error, unexpected T_DOUBLE_ARROW in....  
    

    This line:

      <?= $prototype_helper->link_to_remote(
              'About',
              'update' => 'content',
              'url' => array('action' => 'show_about'),
              'complete' => $scriptaculous_helper->visual_effect('toggle_appear', 'content', array('duration' => 0.5))) ?>  
    

    needs me to state the arrays. ie

           <?= $prototype_helper->link_to_remote(
              'About',
              array('update' => 'content'),
              array('url' => array('action' => 'show_about')),
              array('complete' => $scriptaculous_helper->visual_effect('toggle_appear', 'content', array('duration' => 0.5)))) ?>  
    

    Now I no longer get the error, but the ajax doesn't work. I copied the previous code directly out of the API. It doesn't work even if I take out this line:

             array('complete' => $scriptaculous_helper->visual_effect('toggle_appear', 'content', array('duration' => 0.5)))  
    

    (notice that I changed the code a bit from my previous posts to match the actual code in my app.)
    This has had me stuck for weeks. I really have no idea what's going wrong. I am able to get the Scriptaculous Effect.Toggle('appear') to work in a none Akelos version of my app, but I really want to use Akelos.

    If anyone has had any success with the Scriptaculous toggle_appear effect, please share your knowledge.

    Thank you!

    •  
      CommentAuthorkonus
     

    Ok, I remember that when I use that effect works, but when I try to change different configurations of Ajax.Updater was another history. I could recommend you debug the generated source. I mean, seems like the akelos prototype helper works fine, but the javascript generated could be obsolete or something like that. If you can past here the source maybe could be another way to help you.

    Regards!

    •  
      CommentAuthorbigtalk
     

    Thank you for the reply.
    I'm not exactly sure which source to paste for you. This is the function from scriptaculous_helper.php that I'm using:

    class ScriptaculousHelper extends AkActionViewHelper
    {
    var $_toggle_effects = array('toggle_appear','toggle_slide','toggle_blind');
    
    function visual_effect($name, $element_id = false, $js_options = array())
    {
        $element = $element_id ? Ak::toJson($element_id) : "element";
    
        if (!empty($js_options['queue']) && is_array($js_options['queue'])) {
            $js_queue = array();
            foreach ($js_options['queue'] as $k=>$v){
                $js_queue[] = ($k == 'limit' ? "$k:$v" : "$k:'$v'");
            }
            if(!empty($js_options['queue'])){
                $js_options['queue'] = '{'.join(',',$js_queue).'}';
            }
        }elseif (!empty($js_options['queue'])){
            $js_options['queue'] = "'{$js_options['queue']}'";
        }
    
        if(in_array('toggle_'.$name, $this->_toggle_effects)){
            return "Effect.toggle({$element},'".str_replace('toggle_','',$name)."',".JavascriptHelper::_options_for_javascript($js_options).");";
        }else{
            return "new Effect.".AkInflector::camelize($name)."({$element},".JavascriptHelper::_options_for_javascript($js_options).");";
        }
    }  
    }
    

    If this wasn't what you wanted to see, let me know and I'll dig up whatever is helpful.

    Thanks!