Tag: 行动

我如何在Action中传递一个参数?

private void Include(IList<string> includes, Action action) { if (includes != null) { foreach (var include in includes) action(<add include here>); } } 我想这样称呼 this.Include(includes, _context.Cars.Include(<NEED TO PASS each include to here>)); 这个想法是通过每个包括的方法。

Rails:在一个表单中多次提交button

说我有一个文章模型,并在文章“新”视图中,我有两个button,“发布”和“保存草案”。 我的问题是如何知道在控制器中单击哪个button。 我已经有了一个解决scheme,但是我认为必须有一个更好的方法。 我目前使用的观点是: <div class="actions"> <%= f.submit "Publish" %> <%= f.submit "Save Draft", :name => "commit" %> </div> 所以在控制器中,我可以使用params [:commit]string来处理这个动作。 def create @article = Article.new(params[:article]) if params[:commit] == "Publish" @article.status = 'publish' // detail omitted end @article.save end 但我认为使用视图相关的string是不好的。 你能告诉我另一种方法来完成这个吗? 更新 :由于这些button是在相同的forms,他们都去“创build”的行动,这对我来说是好的。 我想要的是在创build行为中处理这个问题,比如给文章模型一个“状态”栏,并保留“公开”或“草稿”。

如何在Swift中设置UIBarButtonItem的动作

如何设置Swift中的自定义UIBarButtonItem的操作? 以下代码将button成功放置在导航栏中: var b = UIBarButtonItem(title: "Continue", style: .Plain, target: self, action:nil) self.navigationItem.rightBarButtonItem = b 现在,当button被触摸时,我想调用func sayHello() { println("Hello") } 。 我迄今的努力: var b = UIBarButtonItem(title: "Continue", style: .Plain, target: self, action:sayHello:) // also with `sayHello` `sayHello()`, and `sayHello():` 和.. var b = UIBarButtonItem(title: "Continue", style: .Plain, target: self, action:@selector(sayHello:)) // also with `sayHello` `sayHello()`, […]

JavaScript的 – 基于select更改表单操作?

我试图根据下拉菜单中选定的值更改表单操作… 基本上,这个html看起来像这样: <form class="search-form" id="search-form" method="post" accept-charset="UTF-8" action="/search/user"> <select id="selectsearch" class="form-select" name="selectsearch"> <option value="people">Search people</option> <option value="node">Search content</option> </select> <label>Enter your keywords: </label> <input type="text" class="form-text" value="" size="40" id="edit-keys" name="keys" maxlength="255" /> <input type="submit" class="form-submit" value="Search" id="edit-submit" name="search"/> </form> 如果select了“人物”(默认情况下),动作应该是“/ search / user”,如果select了内容,动作应该是“/ search / content” 我仍然在四处搜寻,但一直没能find如何做到这一点…

在C#中使用Action委托

我正在与C#中的Action Delegates合作,希望能够更多地了解它们并思考它们可能的用处。 有没有人使用行动委托,如果是的话,为什么? 或者你能举出一些可能有用的例子吗?

在button动作上传递参数:@selector

我想从我的dynamic生成的button传递电影url到MediaPlayer: [button addTarget:self action:@selector(buttonPressed:) withObject:[speakers_mp4 objectAtIndex:[indexPath row]] forControlEvents:UIControlEventTouchUpInside]; 但action:@selector() withObject:不起作用? 有没有其他解决scheme? 感谢帮助!

手动创build委托与使用Action / Func委托

今天我正在考虑宣布: private delegate double ChangeListAction(string param1, int number); 但为什么不使用这个: private Func<string, int, double> ChangeListAction; 或者如果ChangeListAction没有返回值我可以使用: private Action<string,int> ChangeListAction; 那么在使用delegate关键字声明委托的优势在哪里呢? 是因为.NET 1.1,而.NET 2.0来了Action<T>和.NET 3.5来了Func<T> ?

Java上的条码扫描器实现

好先生,我有一个问题。 我目前正在从事的学校Java项目需要我有一个USB条形码扫描器作为外部input连接到我的笔记本电脑。 我还没有买到USB扫描仪,因为这对学生来说相当昂贵。 所以我必须收集证据表明这个扫描仪将与我的程序工作。 扫描仪是否能够读取条形码(大概是在线打印)并将其存储到variables中? 如果是这样的话,扫描仪按下的动作事件是否会像键盘按键一样被读取? 如果是这样,那么这行代码是什么样的? 另外,如果你可以发表你的经验与条码扫描仪,或给任何build议,如扫描仪购买,这将有助于很多。 干杯!

android从图库中挑选图片

我想从画廊创build一个图片select器。 我使用代码 intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, TFRequestCodes.GALLERY); 我的问题是,在这个活动和video文件显示。 有没有办法来过滤显示的文件,以便在这个活动中不会显示video文件?

action和actionListener之间的区别

action和actionListener之间有什么区别,什么时候应该使用action和actionListener ?