jquery在验证错误后触发(jquery triggered after validation error)
我使用laravel 5.3 / laravelcollective / html 5.2 ..我做了一个复选框,如果选中,隐藏输入会出来,如果我取消选中它,输入将被隐藏..并且从laravel验证请求错误后,复选框仍然存在检查,但隐藏的输入没有显示..请我需要帮助..谢谢..
我的复选框html:
<label> {!! Form::checkbox('penerima_beda', '1', null, ['id' => 'penerima_beda']) !!}Penerima Berbeda </label>
这里是我的jQuery:
$("#penerima_beda").click(function() { if(this.checked){ $("#panel_penerima").css("display", "block"); $("#nama_penerima").attr("required", "required"); $("#no_telp_penerima").attr("required", "required"); $("#alamat_penerima").attr("required", "required"); //console.log(this); }else if(!this.checked){ $("#panel_penerima").css("display", "none"); $("#nama_penerima").removeAttr("required"); $("#no_telp_penerima").removeAttr("required"); $("#alamat_penerima").removeAttr("required"); } });
i am using laravel 5.3 with laravelcollective/html 5.2.. i made a checkbox that if that checked, a hidden input will come out and if i uncheck it the input will be hidden.. and after the validation request error from laravel the checkbox remain checked but the hidden input didnt show up.. please i need help.. thanks..
my checkbox html:
<label> {!! Form::checkbox('penerima_beda', '1', null, ['id' => 'penerima_beda']) !!}Penerima Berbeda </label>
and here is my jquery:
$("#penerima_beda").click(function() { if(this.checked){ $("#panel_penerima").css("display", "block"); $("#nama_penerima").attr("required", "required"); $("#no_telp_penerima").attr("required", "required"); $("#alamat_penerima").attr("required", "required"); //console.log(this); }else if(!this.checked){ $("#panel_penerima").css("display", "none"); $("#nama_penerima").removeAttr("required"); $("#no_telp_penerima").removeAttr("required"); $("#alamat_penerima").removeAttr("required"); } });
原文:https://stackoverflow.com/questions/43175892
最满意答案
所以......今天的主要问题......今天“didSelectRowAt”或其当前Swift标题所在的位置在XCode的主细节模板中,它被替换为什么?
Master Detail模板使用segues。 在这种情况下,你不需要
didSelectRowAt
方法。如果你想找到它,只需在
MasterViewController
输入didSelectRow
,然后选择自动完成建议的第一件事。override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { <#code#> }
当触摸事件被注册以在表视图上选择一行时,什么样的方法序列
该模板使用segues转换到
DetailViewController
。 故事板中的赛段连线。 传输数据的机会在于:prepare(for segue: UIStoryboardSegue, sender: Any?)
注:模板显示使用Storyboard segues时正确使用显示详细视图的方法。
didSelectRowAt
方法会导致混淆,因为它实际上是在prepare(for:sender:)
之后运行的prepare(for:sender:)
并且您可以使用self.tableView.indexPathForSelectedRow
调用来获取prepare(for:sender:)
选定的indexPath
。那么,
didSelectRowAt
仍然有用吗?当然,如果你不使用segues。 在这种情况下,在
didSelectRowAt
内部,你会自己实例化DetailViewController
,配置它,然后按下它。So...main issue today...where did "didSelectRowAt" or whatever its current Swift title is today go in the Master Detail template in XCode and what has it been replaced with???
The Master Detail template is using segues. In that case you don't need the
didSelectRowAt
method.If you want to find it, just type
didSelectRow
inside of theMasterViewController
and choose the first thing that autocomplete suggests.override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { <#code#> }
what the sequence of methods are when a touch event is registered to select a row on the table view
The template is using segues to transition to the
DetailViewController
. The segues are wired in the Storyboard. Your opportunity to transfer data is in:prepare(for segue: UIStoryboardSegue, sender: Any?)
Note: The template shows the correct use of methods for displaying a detail view when using Storyboard segues. The
didSelectRowAt
method causes confusion because it actually runs afterprepare(for:sender:)
and you can get the selectedindexPath
inside ofprepare(for:sender:)
with theself.tableView.indexPathForSelectedRow
call.So, is
didSelectRowAt
still useful?Sure, if you aren't using segues. In that case, inside of
didSelectRowAt
you'd instantiate theDetailViewController
yourself, configure it, and then push it.
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
ios 8和Swift:从视图控制器调用另一个类中的函数(ios 8 and Swift: call a function in another class from view controller)[2022-10-20]
尝试从MyClass之前删除@IBOutlet。 var myClass : MyClass! 你也可以试试这个: var myClass : MyClass! = MyClass() 然而,从它的外观来看,您在MyClass中的setFocus()中所做的所有事情都可以很容易地在ViewController中重新创建。 Try to delete the @IBOutlet from before MyClass. var myClass : MyClass! You can also try th ... -
如果你正在创建一个,我建议使用一个自定义导航控制器进行向下菜单+按钮,它将控制内容菜单和vc,如果你想改变它的根vc,只需设置该自定义导航控制器的vc self.setViewControllers([vc], animated: true) ,其他vc会自动解除自身 If you are creating one, i suggest to use ONE custom navigation controller for the down menu + button, and it will contro ...
-
你试过AFNetworking还是RestKit ? 他们都非常善于使用REST服务。 使用AFNetworking,您可以轻松地进行异步请求并同步处理数据。 RestKit基于AFNetworking,专门为RESTful Web服务客户端而设计,提供了出色的工具。 一探究竟! Have you tried AFNetworking or RestKit? They are both very good with REST services. With AFNetworking you can easil ...
-
所以......今天的主要问题......今天“didSelectRowAt”或其当前Swift标题所在的位置在XCode的主细节模板中,它被替换为什么? Master Detail模板使用segues。 在这种情况下,你不需要didSelectRowAt方法。 如果你想找到它,只需在MasterViewController输入didSelectRow ,然后选择自动完成建议的第一件事。 override func tableView(_ tableView: UITableView, didSelectR ...
-
如果您正在开发针对iOS 8及更高版本的项目,则只会看到“显示”选项,因为它是一项新功能,可帮助您确定显示新视图控制器的正确方法。 如果您在导航控制器中,它将选择“推”,如果您处于常规控制器环境中,它将选择“模态”。 在这里,您可能正在为具有iOS 7或更低版本的部署目标的项目工作。 您可以选择在此处使用“模态”从屏幕底部显示视图控制器并实现退出按钮。 或者,您可以将当前视图控制器嵌入到导航控制器中,使用“推”将新视图控制器从右手推到左手,使用后退按钮自动导航。 You will only see the ...
-
出现< Back按钮,因为您正在执行从登录视图控制器到标签栏控制器的推送segue。 更好的应用程序流将是标签栏控制器是您的初始视图控制器。 然后,在其viewDidAppear方法中,检查用户是否已登录。如果用户未登录,请将模态无动画添加到登录视图控制器。 这一切都会在用户不注意的情况下发生,并允许您想要的故事板设置 The < Back button is appearing because you are doing a push segue from the login view controlle ...
-
iOS Swift UIAlertView(iOS Swift UIAlertView)[2024-03-26]
你可以尝试写这个: func alertView(view: UIAlertView!, clickedButtonAtIndex buttonIndex: Int) { if view == errorAlert { // do your stuff.. } else if view == anotherAlertView { // do your stuff for the second AlertView } } You can try to ... -
一个容器只能嵌入一个segue。 你必须创建2个容器,每个容器都有自己的segue。 或者您可以从代码中添加子控制器,只需创建UIView ,您希望在其中添加子视图控制器并向其添加子控制器视图。 我创建了示例项目以向您展示故事板设置。 @IBOutlet weak var containerView: UIView! ... addChildViewController(controller) containerView.addSubview(controller.view) controller.v ...