如何将onchange动作添加到collection_select?(How do you add onchange action to collection_select?)
我在轨道中有以下选择下拉列表。 我正在遵循API的语法( http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_select ):
collection_select(object,method,collection,value_method,text_method,options = {},html_options = {})
<%= collection_select(:sources, :source_id, Source.all, :id, :name, :include_blank => "Please select a source...", html_options = {:onchange => "updateTextArea()"} ) %> function updateTextArea(){ alert('source changed') }
当我不包含html_options时,我能够得到下拉列表以显示数据库中的值。 但是,我一直试图让onchange动作发生。
I have the following select drop down in my rails. I'm following the syntax from the API( http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_select):
collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {})
<%= collection_select(:sources, :source_id, Source.all, :id, :name, :include_blank => "Please select a source...", html_options = {:onchange => "updateTextArea()"} ) %> function updateTextArea(){ alert('source changed') }
I'm able to get the drop down to display just fine with the values from the DB when I don't include html_options. However, I'm stuck trying to get an onchange action to occur.
原文:https://stackoverflow.com/questions/35707107
最满意答案
是的,可以导入CodeSkulptor中的每个“文件”。
例如,
import user29_SdwDlVVu3J4qvLO
可以导入“文件” http://www.codeskulptor.org/#user29_SdwDlVVu3J4qvLO.py 。好主意是
import user29_SdwDlVVu3J4qvLO as my_modulename
。 见http://www.codeskulptor.org/#user29_fg2U0pzeuTFaCPi.pyYES, each "file" in CodeSkulptor can be imported.
For example, the "file" http://www.codeskulptor.org/#user29_SdwDlVVu3J4qvLO.py can be imported by
import user29_SdwDlVVu3J4qvLO
.The good idea is to make
import user29_SdwDlVVu3J4qvLO as my_modulename
. See http://www.codeskulptor.org/#user29_fg2U0pzeuTFaCPi.py
相关问答
更多-
使用import module as name不会创建别名。 你误解了导入系统。 导入有两件事: 将模块加载到内存中并将结果存储在sys.modules 。 这只做一次 ; 后续导入重新使用已加载的模块对象。 在当前命名空间中绑定一个或多个名称。 使用as name语法可以控制最后一步中的名称。 对于from module import name语法,您仍需要命名完整模块,因为在sys.modules查找module 。 如果你真的想要这个别名,你可以在那里添加额外的引用: import numpy # ...
-
您可以在应用中使用桶。 例如你的组件: // heroes/folder/deep/another/deep/folder/hero.component.ts export class HeroComponent {} 现在您可以在项目的任何文件夹中定义桶,这会导出该模块(按惯例称为索引 ) export * from './heroes/folder/deep/another/deep/folder/hero.component.ts'; // relative path to current fold ...
-
你的代码被缩进了。 此外,还没有定义values 。 但真正的问题可能是frame.start 。 要调用start方法,必须执行frame.start() 。 我做了更正,见: http : //www.codeskulptor.org/#user40_zJYfuypQ0CWRHRA.py Your code is wronged indented. Also values is not defined. But the real problem is probably frame.start. To c ...
-
出于可读性目的,最好在每个文件中导入每个文件。 所以正如你所说的那样,那些来自哪里的文件毫无意义。 因此,为了便于阅读,在每个文件中导入每个文件会更好。 如果你愿意,我可以分享一些例子。 干杯! For readability purposes it would be better to import each one in every file. So as you said it would make no sense with those files coming from no where. So ...
-
我不会考虑让库从我当前的路径或模块中导入好的样式。 相反,我只希望从两个地方导入一个库: 绝对从全局模块空间导入,就像使用pip安装的东西一样。 如果库执行此操作,则还必须在其install_requires=[]列表中找到此库 从内部相对进口。 现在这些是明确导入的. : from . import bla from .bla import blubb 这意味着将对象或模块本地传递到当前作用域必须始终显式发生: from . import scenarios import framework scen ...
-
是的,只需在任何需要的地方导入它。 编写为您导入所有内容的函数或导入内容并从中import *模块时, 不要太聪明; 所有这些只会使您的代码难以阅读,而且只是发生错误的另一个地方。 Yes, just import it everywhere it's needed. Don't get too clever with writing functions that import everything for you or metamodules that import things and from whi ...
-
# determine whether paddle and ball collide if ball_pos[1] > paddle1_pos-HALF_PAD_HEIGHT -2 and ball_pos[1]是的,可以导入CodeSkulptor中的每个“文件”。 例如, import user29_SdwDlVVu3J4qvLO可以导入“文件” http://www.codeskulptor.org/#user29_SdwDlVVu3J4qvLO.py 。 好主意是import user29_SdwDlVVu3J4qvLO as my_modulename 。 见http://www.codeskulptor.org/#user29_fg2U0pzeuTFaCPi.py YES, each "file" in ...在定义具有依赖关系的模块时,这些依赖关系不会在现场加载 - 您只是稍后将它们声明为注入。 此外,Angular在跟随dom ready事件后匹配文档中的ng-app属性之前不会引导。 所以你的代码应该可以正常工作。 演示 When defining modules with dependencies, those dependencies aren't loaded on the spot - you are simply declaring them for injection later. Also, ...好像你在python路径中的某处有SocketServer.py 。 使用以下命令检查: python -c "import SocketServer; print(SocketServer.__file__)" 重命名该文件将解决您的问题。 UPDATE 重命名文件/Users/ddl449/Projects/visualization/SocketServer.py 。 如果有/Users/ddl449/Projects/visualization/SocketServer.pyc ,请删除该文件。 ...
相关文章
更多- Solr In Action
- There is no Action mapped for namespace / and action name register.
- Struts2标签select的使用
- Memcached add 添加key-value命令(存在不会更新)
- Hibernate 异常之:associate a collection with two ...
- 《iBATIS实战》(iBATIS in Action)扫描版[PDF]
- 提交表单时如何既能先表单验证再访问action
- solr搜索提示,将词添加到词库中
- 用好Collection 对solrj入库进行优化
- Solr参数(Analysis Collection Common CoreAdmin)
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)