我目前正在为MooTools编写一个就地编辑脚本,我有点难以理解如何在没有JavaScript的情况下使其优雅地降级,同时还具有一些功能.我想以某种方式使用渐进增强.我不是在寻找代码,而是更多关于如何处理这种情况的概念.如果您有任何想法或知道任何优雅降级的编辑就地脚本,请分享.
javascript mootools progressive-enhancement graceful-degradation edit-in-place
我的问题可以在以下页面中看到:
正确的版本 - > http://appstorereviewer.com/
版本不正确 - > http://appstorereviewer.com/page/2
据我所知,这两个页面在标题中都有相同的javascript.什么会导致主页面正常工作而页面/ 2不能初始化?
第2页引发了两个错误:
1:
window.addEvent is not a function
[Break on this error] window.addEvent('domready', function() {\n
2 line 63
Run Code Online (Sandbox Code Playgroud)
2:
RokTabsOptions is not defined
[Break on this error] RokTabsOptions.duration.push(50);\n
2 line 278
Run Code Online (Sandbox Code Playgroud)
请帮忙
如果我没有提供足够的信息问,我会放更多!
是否可以在MooTools中以百分比形式补充元素?
var slide = new Fx.Tween($('slide_box'));
$('next_slide').addEvent('click',function(){
slide.start('left', '-100%');
});
Run Code Online (Sandbox Code Playgroud)
但是这个代码补间结构为100px,而不是百分之.
我有一个复选框,我想在表单中显示一个取决于是否单击该复选框的字段集?即如果选中该复选框,则不显示该字段集,如果未显示该字段集.
我的标记看起来像这样,
<fieldset class="toplined">
<label>Keep Image</label>
<input type="checkbox" name="update_image[]" value="1" id="toggle" checked='true'/>
</fieldset>
<fieldset class="toplined toggle_slide">
<label>Image:</label>
<input type="file" name="article_image[]">
</fieldset>
Run Code Online (Sandbox Code Playgroud)
类toggle_slide的字段集是我要显示/隐藏的字段集,我目前有这个mootools脚本
$('toggle').addEvent('click', function(e){
e = new Event(e);
$$('.toplined toggle_slide').toggle();
e.stop();
});
Run Code Online (Sandbox Code Playgroud)
但这只会导致错误.
我正在尝试创建一堆元素并将它们插入表中.在FF和Chrome中,我的代码工作正常,但在IE中,当我按下"插入行"按钮时没有任何反应.没有错误或任何事情:\
我已经将我的代码简化为一个简单的例子,试图找到我做错了什么.
function insert_row(){
//get table element
var filterTable = $('table_search_filter');
//create new objects
var tr = new Element('tr');
var td1 = new Element('td');
var td2 = new Element('td');
var td3 = new Element('td');
var select_project = new Element('select', {'id':'select_secondary_' + filterCounter});
//add elements to table
td2.grab(select_project);
tr.grab(td1);
tr.grab(td2);
tr.grab(td3);
filterTable.grab(tr);
}
Run Code Online (Sandbox Code Playgroud)
当我写出我的tr元素innerHTML时,我在FF和IE中得到不同的结果:
FF - <td></td><td><select id="select_secondary_0"></select></td><td></td>
IE - <TD></TD><TD><SELECT id=select_secondary_0></SELECT></TD><TD></TD>
所以看起来IE处理它的方式不同.首先,标签是大写的,这是不好的.其次,我的身份没有'人物.为什么?我现在真的很困惑,漫长的一天:
美好的一天.
请原谅我对MooTools的体验.
总之,CMS生成此代码:
<div class="gk_tab gk_tab-style1 clearfix-tabs" id="slideshow-tabs" style="width: 418px; ">
<ul class="gk_tab_ul-style1">
<li id="slideshow-tabs_tab_1" class="active"><span>Video</span></li>
<li id="slideshow-tabs_tab_2" class=""><span>Calendar</span></li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
我需要能够在页面加载时插入此代码:
<li id="slideshow-tabs_tab_0" class=""><a><span>Video</span></a></li>
Run Code Online (Sandbox Code Playgroud)
在特定的空间.最终结果应该是:
<div class="gk_tab gk_tab-style1 clearfix-tabs" id="slideshow-tabs" style="width: 418px; ">
<ul class="gk_tab_ul-style1">
<li id="slideshow-tabs_tab_0" class=""><a><span>Video</span></a></li>
<li id="slideshow-tabs_tab_1" class="active"><span>Video</span></li>
<li id="slideshow-tabs_tab_2" class=""><span>Calendar</span></li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
所以我知道我需要使用我想要添加的新HTML创建一个新元素然后插入它,但不确定如何尽可能高效.哦,是的,我有一个特定的理由需要这样做,但不想让所有额外的信息和代码陷入这篇文章.非常感谢提前!我会在这里继续搜索,看看能不能弄明白.
PS.我正在插入它的类存在于页面的其他部分.所以我必须确保指定id ="slideshow-tabs".
我正在尝试实现一个没有jQuery的移动照片滑块,它使用moo工具
我想要一个像这个家伙的滑块http://mahusay-fbt.blogspot.com/
所以我在这里获得了专门为博客设计的那段代码bit.ly/chXo9Q
我在我的虚拟博客上实现了它,它无法正常工作
这是我得到的错误
Uncaught SyntaxError: Unexpected number
hacktheplanets.blogspot.com/:1380 Uncaught ReferenceError: Class is not defined
hacktheplanets.blogspot.com/:1657 Uncaught TypeError: Object [object DOMWindow] has no method 'addEvent'
Run Code Online (Sandbox Code Playgroud)
我不知道我哪里出错了,我需要帮助
在互联网上使用HTML5和CSS3有相当多的页面翻转/卷曲效果,但似乎我找不到任何页面折叠效果(将页面向左和向右折叠到中间).
有关使用哪种工具的建议/建议?Mootools?
我不习惯使用mooTools,它看起来很像Prototype JS.谁能告诉我如何将它绑定到每个班级?
// This grabs all the classes
var mousy = $$('.hf-item-images');
// I don't think this is correct to apply this scroller to all the above classes
var scroll = new Scroller(mousy, {area: 100, velocity: 1});
// Mousemove
mousy.addEvent('mouseover', scroll.start.bind(scroll));
mousy.addEvent('mouseout', scroll.stop.bind(scroll));
Run Code Online (Sandbox Code Playgroud) 我有一个非常基本的问题,我找不到答案,我确实检查了mootools网站,但我还没有完全掌握这个概念:
在mootools中你有一个函数.bind(),它可以按如下方式使用:
function customFunction () {
this.setStyle('color','blue');
}
var boundFunction = customFunction.bind(myElement);
boundFunction(); //Now the color of the element is changed to red
// To show how bind works the following example:
var myBoundFunction = myFunction.bind(anyVar);
// is roughly equivalent with
var myBoundFunction = function(){
return myFunction.call(this);
};
Run Code Online (Sandbox Code Playgroud)
但为什么不这样做呢?
function customFunction (parameter) {
parameter.setStyle('color','blue');
}
customFunction(myElement);
Run Code Online (Sandbox Code Playgroud)
这似乎更有效率?
我的一个大问题是:使用.bind()会是一个好习惯,为什么会这样?