javascript 好用及常用函数(ruby)

1.js延时与动态显示

  new Ajax.Updater('yourid', 'rails/info/properties', {   
    method:     'get',   
    onFailure:  function() {Element.classNames('yourid').add('failure')},   
    onComplete: function() {new Effect.BlindDown('yourid', {duration: 0.25})}   
//有慢慢向下效果

  });   
} else {   
  new Effect[Element.visible('yourid') ?    
    'BlindUp' : 'BlindDown']('yourid', {duration: 0.25});  # 根据判断有向上或向下效果
}  

 延时用 duration: 0.25 delay:3

 

2.显示与隐藏层 结合rial 的Ajax 有londing 效果

<%= link_to_remote "Say Hello", 
                    :url => tasks_url(:action => 'hello'),
                    :loading => "Element.show('loading')",
                    :complete => "Element.hide('loading')" %>

 3.延时

  page.delay(0.3) do
                   page.replace_html 'countdown', '<div id="countdownGO">GO!</div>'
                   page.visual_effect :puff, 'countdown', :duration => 0.5
                        page.delay(0.3) do
                       page.visual_effect :fade, 'profile-indicator'  #淡淡消失
                       page.visual_effect :squish, "tosquish"   #发出咯吱的声音失
                                  page.visual_effect:highlight, "important", :duration => 1.5#高亮
                       page.replace_html 'info', :partial => 'info/test'
                    end
                end
更多效果
new Effect.Highlight visual_effect(:highlight) 高亮
new Effect.Appear visual_effect(:appear)   出现






new Effect.Fade visual_effect(:fade)  褪去, (使)变弱, (使)枯萎
 new Effect.Puff visual_effect(:puff)   一阵喷烟, 肿块一缕(烟、蒸汽等






new Effect.BlindDown visual_effect(:blind_down)    细枝条改变, 转变












new Effect.BlindUp visual_effect(:blind_up) 
new Effect.SwitchOff visual_effect(:switch_off)    
 new Effect.SlideDown visual_effect(:slide_down)   滑动; 滑行






new Effect.SlideUp visual_effect(:slide_up)
 new Effect.DropOut visual_effect(:drop_out)
 new Effect.Shake visual_effect(:shake)     摇动, 震动, 颠簸






new Effect.Pulsate visual_effect(:pulsate)   跳动,有节奏的跳动,震动






 new Effect.Squish visual_effect(:squish)  咯吱声,果酱






new Effect.Fold visual_effect(:fold)     折叠; 对折交叠






 new Effect.Grow visual_effect(:grow)  生长, 发育






 new Effect.Shrink visual_effect(:shrink)  收缩; 退缩






 new Effect.ScrollTo visual_effect(:scroll_to)  卷形花纹

 

 得当前对象的子节点某一声名元素的集合,为数组

               var a =obj.getElementsByTagName('a');
               alert(a[0].innerHTML);

大小写转换:

var result = ss.toLowerCase();  zhuan wei  xiap xie 
var result = ss.toUpperCase(); zhuan wei da xie 










  page.toggle('id')

显示与隐藏切换

你可能感兴趣的:(JavaScript,Ajax,Ruby,UP,Rails)