- 浏览: 2676780 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
80后的童年2:
深入浅出MongoDB应用实战开发网盘地址:https://p ...
MongoDB入门教程 -
shliujing:
楼主在不是精通java和php的前提下,请不要妄下结论。
PHP、CakePHP哪凉快哪呆着去 -
安静听歌:
希望可以一给一点点注释
MySQL存储过程之代码块、条件控制、迭代 -
qq287767957:
PHP是全宇宙最强的语言!
PHP、CakePHP哪凉快哪呆着去 -
rryymmoK:
深入浅出MongoDB应用实战开发百度网盘下载:链接:http ...
MongoDB入门教程
ActionView为我们封装RJS代码到update_page()块里面,比如thought_log的例子会生成如下代码:
当partial中需要变量时我们可以这样做:
RJS中的page实际为一个JavaScriptGenerator对象,它可以做Element/Class/Collection的Proxies
Element Proxies:
Class Proxies:
我们在public/javascripts/application.js里添加一个JavaScript类
然后我们可以这样调用Alerter类
Collection Proxies
页面上的helper方法
This is most common way to make an Ajax call with Rails. link_to_remote() is a helper that generates a hyperlink that makes an Ajax request when clicked. Rails generates either an Ajax.Request or an Ajax.Updater in the onclick() event of the <a> tag, depending on whether or not the :update option was passed to link_to_remote(). For the purposes of RJS, the :update option should not be used because the Prototype Ajax.Updater object expects an HTML response and RJS returns a JavaScript response. If you are having any weird problems with parts of your RJS response appearing on your page, then you're probably using the :update option with an RJS template.
Generates a hyperlink that executes a JavaScript function or code when clicked. This doesn't actually create an Ajax request, but it can be used to execute custom JavaScript functions that do. Use this method to call your custom JavaScript libraries that use Ajax.Request to make the Ajax calls.
Observes a field and makes an Ajax request when the content has changed or the event specified withn has occurred
Generates the JavaScript to make a background Ajax request to a remote controller action. This method is useful for making remote Ajax calls from the event handlers of DOM objects, such as the onchange() event of a <select> tag. Takes the same options as link_to_remote().
Works just like observe_field(), but observes an entire form.
Creates a form tag that submits the contents of the form using a background Ajax request. This is another very common way to make Ajax requests.
Just like form_remote_tag(), but uses the form_for semantics introduced in Rails 1.1.
Creates a button that will submit the contents of the parent form to the remote controller action. The options are the same as for form_remote_tag().
Makes an Ajax request when changes to the field are committed. To use this method with RJS you have to pass in the option :script => true to the in_place_editor_options hash.
This is the method that the in_place_editor_field() wraps. To use this method with RJS you need to pass in the :script => true option to the options hash.
Makes an Ajax request when droppable elements are dropped onto the element.
An Ajax request is made whenever this element is sorted using drag and drop.
All Rails helpers use this Prototype object to make the actual Ajax requests. You can also use this object to make remote Ajax requests from your JavaScript libraries. This is a JavaScript object and not a Ruby object.
我们还可以写helper方法给RJS模板使用,例如:
然后我们就可以在RJS模板中这样使用了:
update_page do |page| page.insert_html :bottom, 'thoughts', :partial => 'thought' page.visual_effect :highlight, 'thoughts' page.form.reset 'thought-form' end
当partial中需要变量时我们可以这样做:
page.replace_html 'user', :partial => 'user', :locals => { :name => 'Cody Fauser', :title => 'EL Presidente'}
RJS中的page实际为一个JavaScriptGenerator对象,它可以做Element/Class/Collection的Proxies
Element Proxies:
page['header'].hide page[:header].hide page[:header].hide.show
Class Proxies:
我们在public/javascripts/application.js里添加一个JavaScript类
var Alerter = { displayMessage: function(text) { alert(text); } }
然后我们可以这样调用Alerter类
page.alerter.display_message('Welcome')
Collection Proxies
page.select('#content p') page.select('#content p').each do |element| element.hide end page.select('#form input[type=text]').each do |element| element.hide end
页面上的helper方法
link_to_remote(name, options = {}, html_options = {})
This is most common way to make an Ajax call with Rails. link_to_remote() is a helper that generates a hyperlink that makes an Ajax request when clicked. Rails generates either an Ajax.Request or an Ajax.Updater in the onclick() event of the <a> tag, depending on whether or not the :update option was passed to link_to_remote(). For the purposes of RJS, the :update option should not be used because the Prototype Ajax.Updater object expects an HTML response and RJS returns a JavaScript response. If you are having any weird problems with parts of your RJS response appearing on your page, then you're probably using the :update option with an RJS template.
link_to_function(name, function, html_options = {})
Generates a hyperlink that executes a JavaScript function or code when clicked. This doesn't actually create an Ajax request, but it can be used to execute custom JavaScript functions that do. Use this method to call your custom JavaScript libraries that use Ajax.Request to make the Ajax calls.
abserve_field(field_id, options = {})
Observes a field and makes an Ajax request when the content has changed or the event specified withn has occurred
remote_function(options)
Generates the JavaScript to make a background Ajax request to a remote controller action. This method is useful for making remote Ajax calls from the event handlers of DOM objects, such as the onchange() event of a <select> tag. Takes the same options as link_to_remote().
observe_form(form_id, options = {})
Works just like observe_field(), but observes an entire form.
form_remote_tag(options = {})
Creates a form tag that submits the contents of the form using a background Ajax request. This is another very common way to make Ajax requests.
form_remote_for(object_name, object, options = {}, &proc)
Just like form_remote_tag(), but uses the form_for semantics introduced in Rails 1.1.
submit_to_remote(name, value, options = {})
Creates a button that will submit the contents of the parent form to the remote controller action. The options are the same as for form_remote_tag().
in_place_editor_field(object, method, tag_options = {}, in_place_editor_options = {})
Makes an Ajax request when changes to the field are committed. To use this method with RJS you have to pass in the option :script => true to the in_place_editor_options hash.
in_place_editor(field_id, options = {})
This is the method that the in_place_editor_field() wraps. To use this method with RJS you need to pass in the :script => true option to the options hash.
drop_receiving_element(element_id, options = {})
Makes an Ajax request when droppable elements are dropped onto the element.
sortable_element(element_id, options = {})
An Ajax request is made whenever this element is sorted using drag and drop.
Ajax.Request(url, options)
All Rails helpers use this Prototype object to make the actual Ajax requests. You can also use this object to make remote Ajax requests from your JavaScript libraries. This is a JavaScript object and not a Ruby object.
我们还可以写helper方法给RJS模板使用,例如:
def insert_item(list_id, item) page.insert_html :bottom, list_id, '<li>#{item.title}</li>' page.visual_effect :highlight, 'item #{item.id}', :duration => 0.5 end
然后我们就可以在RJS模板中这样使用了:
page.insert_item 'my_list', @item
发表评论
-
用了TextMate才知道什么叫神级Editor
2011-03-09 04:51 57955一直用Eclipse作为开发Ruby和Java项目的IDE,但 ... -
Ruby使用OAuth登录新浪微博和豆瓣
2011-01-09 12:49 4427首先需要安装oauth这个gem包 gem install ... -
使用Passenger+nginx部署Rails
2010-12-28 15:12 50081. Install Passender gem instal ... -
markItUp+rdiscount搭建Rails下可视化Markdown编辑器
2010-12-21 17:48 5443markItUp是基于jQuery的可视化编辑器,支持Html ... -
Rails3 and MongoDB Quick Guide
2010-12-10 14:13 2751Install MongoDB Download: http: ... -
基于ruby-protobuf的rpc示例
2009-08-11 11:51 41481, 安装ruby-protobuf gem instal ... -
Ruby导出xls和csv的utf-8问题的解决
2009-02-04 15:05 6833数据库数据为utf-8格式,包括中文和拉丁文等等 导出文件xl ... -
URL/HTML/JavaScript的encode/escape
2009-01-04 13:03 9323最近经常被URL、HTML、JavaScript的encode ... -
各种排序的Ruby实现
2008-11-27 14:51 3994Θ(n^2) 1, Bubble sort def bu ... -
12月5日北京RoR活动!
2008-11-26 18:38 3016又是一年过去了,Rails在国内的发展势态良好,很多使用RoR ... -
Rails程序开发的最大问题是代码规范
2008-08-28 11:56 5503使用Rails开发大型复杂B2B应用一年了,这个项目目前开发人 ... -
Web开发大全:ROR版——推荐序
2008-07-09 00:39 2414来自http://www.beyondrails.com/bl ... -
深入ActionMailer,使用Sendmail发邮件
2008-07-03 11:41 3395来自: http://www.beyondrails.com/ ... -
Rails里如何结合ExceptionNotification配置gmail账户发邮件
2008-06-19 19:56 30771,安装ExceptionNotification rub ... -
使用coderay和railscasts样式进行代码高亮
2008-06-17 00:16 2394CodeRay是一个语法高亮的Ruby库,效率很不错。 Cod ... -
Capistrano试用
2008-06-16 19:05 19551,客户端机器安装Capistrano gem insta ... -
lighttpd真垃圾啊
2008-06-04 18:38 2525使用lighttpd+fcgi跑Rails程序,文件上传会si ... -
将gem变成plugin
2008-06-04 11:27 1799有什么样的需求就有什么样的对策 当vhost上的帐号没有ge ... -
在Rails里使用ReCaptcha添加验证码
2008-06-03 15:51 42621,去http://recaptcha.net/sign up ... -
Rails里给文件上传添加progress_bar
2008-05-27 17:00 2085文件上传很慢时,UI没有什么用户提示,这样让人很费解,所以我们 ...
相关推荐
在Rails中,RJS通过ActionView的辅助方法与控制器的action配合工作,生成JavaScript代码,这些代码可以在客户端执行,从而动态改变网页。 描述中提到的“博文链接:https://hlee.iteye.com/blog/354530”是一个可能...
3. **脚本执行**:可以调用JavaScript函数或者设置JavaScript变量,使客户端代码与服务器端数据同步。 4. **响应处理**:在处理Ajax请求的控制器中,可以返回一个rjs模板,动态更新页面并反馈给用户。 在描述中...
在进行条码检测时,要确保条码与检测仪之间的距离合适,以及光线条件适宜,避免因光照不足或过强导致误读。RJS D4000+通常具备自动调焦功能,可以适应不同大小的条码。同时,设备还可能提供实时反馈,显示条码的等级...
6. 售后服务与购买咨询: 售后和购买咨询是用户在选择和使用条码检测仪时不可或缺的一部分。用户在购买前可能需要咨询设备的功能、价格、使用效果等问题,而在购买后,如果遇到操作上的疑问或设备故障,也需要及时...
在Rails框架中,RJS模板通常与ActionController的`render :update`或`render :js`方法一起使用。这些方法会触发一个RJS模板的执行,生成的JavaScript代码会被发送到客户端并在浏览器中执行。通过这种方式,开发者...
根据给定的文件信息,关于RJS D4000+条码检测仪的中文设置操作手册,这里可以提炼出一系列相关知识点,帮助用户更好地理解和操作该款条码检测仪。以下知识点涵盖了从条码检测仪的基本概念、操作到维护保养等多方面的...
RJS D4000+条码检测仪分析结果说明书以及使用过程中注意事项。
在`r.js`与`Node.js`结合使用时,`Node.js`作为一个强大的服务器端环境,提供了丰富的模块系统和非阻塞I/O操作,使得`r.js`的运行更加高效。`r.js`可以作为Node.js的模块运行,利用Node.js的文件系统API读取和处理...
文章内容部分提及了计算机视觉与模式识别技术的进步,并且明确指出智能车辆领域已经成为智能交通系统研究的主流课题。以下是对文章内容的详细解析: 首先,文章提到的“无人驾驶自动驾驶智能汽车”是一个高度依赖于...
Rust上JavaScript rjs是Rust中的本机JavaScript实现。该项目rjs的目标是在Rust中提供一种快速的本机JavaScript实现。 当前rjs处于alpha状态,这意味着性能和稳定性不能代表我们想要的最终结果,并且公共API可能仍会...
"calmjs.rjs"这个名字可能暗示它与JavaScript(RJS可能代表“Runtime JavaScript”)有关,可能是为了在Python环境中处理或操作JavaScript代码而设计的库。 "calmjs.rjs-1.0.0.tar.gz"的文件名结构遵循了Python包的...
RJS.Web.WebControl.PopCalendar.dll下载,用于网页asp 时间选取周别
page.drop_receiving 'photo', :url => { :action => 'add' } ``` **生成的JavaScript代码**: ```javascript Droppables.add("photo", { onDrop: function(element) { new Ajax.Request('/hello_world/add', { ...
rjs:R中的建模。JavaScript中的交互性。 rjs旨在帮助您利用JavaScript的可视化库和R的建模包来构建量身定制的交互式应用程序。 (这是的重构版本,在很大程度上是向后兼容的。我不久jsReact教程rjs到rjs ,现在请...
4. **校准与调整**:条码检测仪的光学系统需要定期校准以保持精度。遵循制造商的校准指南,确保设备的读取参数设置正确。 5. **故障排除流程**:遵循“由简单到复杂”的原则,从最有可能的问题开始排查,例如电源、...
gulp-require-rjs 扩展代码形式 r.js优化插件描述到r.js的gulp接口。 您可以使用r.js优化器同时打包多个文件。 可以将参数直接传递到r.js。 添加一个名为outPath的参数,以便可以更改打包方式; 默认值为baseUrl 。...
rjs:JavaScript中的R 在JavaScript中引入R,这是一种由支持的将R代码直接插入网站的。 您可以通过2个简单的步骤使用它。步骤1 在html文件的任意位置添加[removed][removed] (或在本地下载r.js )。第2步将class = ...
gulp-rjs2 gulp 的 Requirejs 插件,支持组件模式 安装 使用安装 npm install --save-dev gulp-rjs2 用法 var rjs = require ( 'gulp-rjs2' ) ; // build libs.js gulp . task ( 'rjs-libs' , function ( ) { //...
标题中的“RJS-PHPScripts-开源”表明这是一个基于PHP的开源项目,可能是由RJS开发的一系列脚本集合。这些脚本的核心特点是它们不依赖于常见的MySQL数据库,而是采用了PHP-Text-Db-Api作为数据存储和管理的解决方案...