RJS参考之JavaScriptGenerator

编程入门 行业动态 更新时间:2024-10-09 19:21:14

<a href=https://www.elefans.com/category/jswz/34/390083.html style=RJS参考之JavaScriptGenerator"/>

RJS参考之JavaScriptGenerator

RJS模板中的page即JavaScriptGenerator类的对象,它有如下方法:
[code]
<<(javascript)
[/code]
Writes raw JavaScript to the page.

[code]
[](id)
[/code]
Returns a JavaScriptElementProxy for the DOM element with the specified id. Methods can be called on the returned element. Multiple method calls can also be chained together.

[code]
assign(variable, value)
[/code]
Assigns a value to the JavaScript variable specified. Ruby objects are automatically converted to JavaScript objects by calling the object's to_json method if it has one, or inspect if it doesn't.

[code]
alert(message)
[/code]
Displays a JavaScript alert dialog box with the provided message.

[code]
call(function, arg, ...)
[/code]
Calls a JavaScript function and passes in zero or more arguments.

[code]
delay(seconds = 1)
[/code]
Executes the code within the block after delaying for the specified number of seconds.

[code]
draggable(id, options = {})
[/code]
Makes the DOM element specified by the id draggable.

[code]
drop_receiving( id, options = {})
[/code]
Makes the DOM element specified by the id receive dropped draggable elements. Draggable elements are created using the RJS draggable method or by using draggable_element() Scriptaculous helper.

[code]
hide(id, ...)
[/code]
Hides one or more DOM elements. Specify the elements to hide by their DOM ids.

[code]
insert_html(position, id, *options_for_render)
[/code]
Inserts the HTML into the specified position in relation to the element.
The available positions are:
:before
The content is inserted into the page before the element.
:after
The content is inserted into the page after the element.
:top
The content is inserted into the element before the element's existing content.
:bottom
The content is inserted into the element after the element's existing content.

[code]
redirect_to(location)
[/code]
Redirect the browser to the location specified. redirect_to() passes the location to url_for(), so any of the arguments you normally use with url_for() can also be used with redirect_to().

[code]
remove(id, ...)
[/code]
Removes one or more DOM elements from the page.

[code]
replace(id, *options_for_render)
[/code]
Replaces the entire element specified or outerHTML. replace is useful with partial templates so that the entire partial, which includes a container element, can be rendered and used to replace content during an RJS call. An example is an unordered list. A partial containing a <li> tag can be rendered instead of having to replace the innerHTML of the <li> . Replacing just the innerHTML would require the <li> tag to be moved out of the partial.

[code]
replace_html(id, *options_for_render)
[/code]
Replaces the content or innerHTML of the DOM element with the id with either a String or the output of a rendered partial template.

[code]
select(pattern)
[/code]
Selects DOM elements using CSS-based selectors. Returns a JavaScriptElementCollectionProxy that can then receive proxied enumerable methods. See the JavaScriptCollectionProxy methods in the next section.

[code]
sortable(id, options = {})
[/code]
Makes the element with the DOM ID id sortable using drag and drop. The options are the same as the options for ScriptaculousHelper#sortable_element().

[code]
show(id, ...)
[/code]
Makes one or more hidden DOM elements visible. As with hide(), the elements are specified by their DOM ids.

[code]
toggle(id, ...)
[/code]
Toggles the visibility of one or more DOM objects.

[code]
visual_effect(name, id = nil, options = {})
[/code]
Creates a new Scriptaculous visual effect to the element with the DOM id. See the following section on visual effects for a list of the visual effects shipping with Rails 1.1.

更多推荐

RJS参考之JavaScriptGenerator

本文发布于:2024-03-15 02:15:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1737887.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:RJS   JavaScriptGenerator

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!