`
hideto
  • 浏览: 2679409 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

RJS参考之JavaScriptCollectionProxy

    博客分类:
  • Ruby
阅读更多
JavaScriptGenerator#select()返回一个JavaScriptElementCollectionProxy类的实例,它继承于JavaScriptCollectionProxy。
JavaScriptCollectionProxy有一些方法:

all(variable) {|value,index| block }

Each element is passed to the block. The block is converted to a JavaScript iterator function. The JavaScript variable is set to TRue if the iterator function never returns false or null.

any(variable){|value, index| block }

Each element is passed to the block. The block is converted to a JavaScript iterator function. The JavaScript variable is set to TRue if the iterator function never returns false or null.

collect(variable){|value, index| block }

The block is converted to a JavaScript iterator. This method assigns a new JavaScript Array to the JavaScript variable containing the results of executing the iterator function once for each element.

detect(variable){|value, index| block }

Each element is passed to the given block. The block is converted to a JavaScript iterator function. The JavaScript variable is assigned to the first element for which the iterator function does not return false.

each{|value, index| block }

Passes each element to the block, which is converted to a JavaScript iterator function. The iterator function is called once for each element.

find(variable){|value, index| block }

A synonym for JavaScriptCollectionProxy#detect().

find_all(variable){|value, index| block }

Each element is passed to the given block. The block is converted to a JavaScript iterator function. The JavaScript variable is assigned to an Array of all elements for which the iterator function does not return false.

grep(variable, pattern){|value, index| block }

Each DOM element with a toString() matching the Regexp pattern is passed to the given block. The block is converted to a JavaScript iterator function. The JavaScript variable is assigned to an Array containing the results of executing the iterator function once for each element.
This method isn't entirely useful in the context of RJS. Its only real use is matching DOM elements using the pattern based on their type, which is output by the toString() method. The toString() method outputs [object HTMLDivElement] for a <div> element. Use the FireBug console to view the toString() output for other elements.

inject(variable, memo){|memo, value, index| block }

Each element and the accumulator value memo is passed to the given block. The block is converted to a JavaScript iterator function. The iterator function is called once for each element and the result is stored in memo. The result returned to the JavaScript variable is the final value of memo. The initial value of memo is set in one of two ways. The value of the parameter memo is used as the initial value if a non nil value is passed in to the method. Otherwise, the first element of the collection is used as the initial value.

map(variable){|value, index| block }

Synonym for JavaScriptCollectionProxy#collect().

max(variable){|value, index| block }

Each element is passed to the given block. The block is converted to a JavaScript iterator function. The JavaScript variable is assigned to the largest value returned by the iterator function.

min(variable){|value, index| block }

Each element is passed to the given block. The block is converted to a JavaScript iterator function. The JavaScript variable is assigned to the smallest value returned by the iterator function.

partition(variable){|value, index| block }

Each element is passed to the given block. The block is converted to a JavaScript iterator function and is executed once for each element. The JavaScript variable is set to an Array containing to Arrays. The first Array contains all of the elements for which the iterator function evaluated to true. The second Array contains all of the remaining elements.

pluck(variable, property)

Iterates through the collection creating a new Array from the value of the given property of each object without a function call. The resulting Array is assigned to the JavaScript variable.

reject(variable){|value, index| block }

Each element is passed to the given block. The block is converted to a JavaScript iterator function. The JavaScript variable is assigned to an Array of all elements for which the iterator function returns false.

select(variable){|value, index| block }

A synonym for JavaScriptCollectionProxy#find_all().

sort_by(variable){|value, index| block }

Each element is passed to the given block. The block is converted to a JavaScript iterator function. Assigns the JavaScript variable to an Array of the elements sorted using the result of the iterator function as keys for the comparisons when sorting.

zip(variable, arg1, ...){|value, index| block }

Merges elements with the arrays passed as parameters. Elements in the corresponding index of each array form a new array. The resulting array of arrays is assigned to the JavaScript variable. If a block is provided it is converted to an iterator function and is applied to each resulting Array. The name of the parameter to the iterator function is array.
分享到:
评论

相关推荐

    RJS D4000+条码检测仪中文操作说明书

    同时,会参考提供的部分内容信息。 在实际内容生成前,需要明确的是,RJS D4000+条码检测仪是一种用于检测条码质量的专业设备。它对于条码印刷、打印质量控制和条码识读设备的性能评估等方面具有重要作用。该设备...

    条码检测仪RJS D4000+中文操作说明书

    **条码检测仪RJS D4000+中文操作说明书** 在信息技术高度发达的今天,条码作为数据传输和管理的重要工具,广泛应用于零售、物流、医疗等多个领域。条码检测仪,如RJS D4000+,是确保条码质量和效率的关键设备。本文...

    rjs 技术

    **rjs技术** rjs,全称Ruby JavaScript,是一种在Ruby on Rails框架中结合JavaScript的编程方式,主要用于创建动态和交互式的网页应用。它允许开发者使用Ruby语法来编写JavaScript代码,使得JavaScript的编写更加...

    RJSD4000条码检测仪 RJS D4000+中文设置操作手册

    根据给定的文件信息,关于RJS D4000+条码检测仪的中文设置操作手册,这里可以提炼出一系列相关知识点,帮助用户更好地理解和操作该款条码检测仪。以下知识点涵盖了从条码检测仪的基本概念、操作到维护保养等多方面的...

    一些RJS资源和演示入门教程

    标题中的“一些RJS资源和演示入门教程”指的是与Ruby JavaScriptSerializer (RJS)相关的学习材料和实践示例,这是一门技术,主要用于在Rails框架下生成JavaScript代码。RJS通常用于更新页面的部分内容,无需刷新整个...

    RJS D4000+等级条码检测仪扫描结果说明书

    RJS D4000+条码检测仪分析结果说明书以及使用过程中注意事项。

    RJS Templates for Rails

    **RJS Templates for Rails** RJS模板是Rails框架在1.1版本中引入的一种创新且功能强大的新模板类型。它们的出现极大地提升了Rails应用中JavaScript的编写效率和可维护性,尤其是在处理动态交互和页面更新时。RJS,...

    rjs配合node压缩材料

    在IT行业中,优化资源加载和提高页面性能是至关重要的任务之一。`r.js`、`require.js` 和 `Node.js` 是在这个领域中常见的工具,它们在JavaScript模块管理和构建流程中发挥着重要作用。这里我们将深入探讨这三个工具...

    无人驾驶自动驾驶智能汽车:理论,算法和实现【5rjs.cn】

    在本篇文章中,涉及的知识点主要围绕“无人驾驶自动驾驶智能汽车”的理论、算法以及实现技术展开。文章内容部分提及了计算机视觉与模式识别技术的进步,并且明确指出智能车辆领域已经成为智能交通系统研究的主流课题...

    rjs:Rust JavaScript解释器

    Rust上JavaScript rjs是Rust中的本机JavaScript实现。该项目rjs的目标是在Rust中提供一种快速的本机JavaScript实现。 当前rjs处于alpha状态,这意味着性能和稳定性不能代表我们想要的最终结果,并且公共API可能仍会...

    PyPI 官网下载 | calmjs.rjs-1.0.0.tar.gz

    《PyPI官网下载:calmjs.rjs-1.0.0.tar.gz——探索Python库的奥秘》 PyPI(Python Package Index)是Python开发者的重要资源库,它提供了无数的开源库,使得Python编程更加便捷高效。今天我们将聚焦于在PyPI上找到...

    RJS.Web.WebControl.PopCalendar.dll

    RJS.Web.WebControl.PopCalendar.dll下载,用于网页asp 时间选取周别

    RJS Cheatsheet

    ### RJS Cheatsheet知识点详解 #### 一、RJS简介 RJS(Remote JavaScript Template)是Ruby on Rails框架中的一个特殊组件,用于在服务器端生成JavaScript代码,并将其发送到客户端执行,从而实现动态更新页面的...

    rjs:R包

    rjs:R中的建模。JavaScript中的交互性。 rjs旨在帮助您利用JavaScript的可视化库和R的建模包来构建量身定制的交互式应用程序。 (这是的重构版本,在很大程度上是向后兼容的。我不久jsReact教程rjs到rjs ,现在请...

    条码检测仪RJS D4000+ HHP/honeywell QC800故障和维修指导

    本文将重点介绍RJS D4000+和HHP/Honeywell QC800这两款条码检测仪的常见故障及维修方法。 RJS D4000+是一款高级的条码检测仪,它提供了精确的条码分析和评估,以满足各种行业标准。当遇到设备故障时,首先要检查...

    gulp-require-rjs

    gulp-require-rjs 扩展代码形式 r.js优化插件描述到r.js的gulp接口。 您可以使用r.js优化器同时打包多个文件。 可以将参数直接传递到r.js。 添加一个名为outPath的参数,以便可以更改打包方式; 默认值为baseUrl 。...

    rjs:JavaScript中的R

    rjs:JavaScript中的R 在JavaScript中引入R,这是一种由支持的将R代码直接插入网站的。 您可以通过2个简单的步骤使用它。步骤1 在html文件的任意位置添加[removed][removed] (或在本地下载r.js )。第2步将class = ...

    gulp-rjs2:gulp 的 Requirejs 插件,支持组件模式

    gulp-rjs2 gulp 的 Requirejs 插件,支持组件模式 安装 使用安装 npm install --save-dev gulp-rjs2 用法 var rjs = require ( 'gulp-rjs2' ) ; // build libs.js gulp . task ( 'rjs-libs' , function ( ) { //...

Global site tag (gtag.js) - Google Analytics