Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

初始状态无法呈现 #10

Open
sicaboy opened this issue Oct 19, 2019 · 2 comments
Open

初始状态无法呈现 #10

sicaboy opened this issue Oct 19, 2019 · 2 comments

Comments

@sicaboy
Copy link

sicaboy commented Oct 19, 2019

先上代码:

$form->switch('custom_position', '自定义位置');
...
$subscriber_script = $this->createSubscriberScript($form, function($builder) {
    $builder->subscribe('custom_position', 'switchchange', function ($event) {
    return <<< EOT
       function (data) {
            if (data == 'on'){
                 $('.form-group:last-child').slideDown();
            }else{
                 $('.form-group:last-child').slideUp();
            }
        }
EOT;
});
});
...

创建的form

custom_position 这个switch是默认关闭的, 也就是说 .form-group:last-child 这个元素默认需要调用一次. slideUp()的

编辑的form

custom_position 这个switch是可能是开着可能是关着, .form-group:last-child 这个元素需要根据switch来变化

猜想的解决方案

应该在页面form页面读取完成之后,调用一次subscribe的脚本.

@zuweie
Copy link
Owner

zuweie commented Oct 30, 2019

?

@sicaboy
Copy link
Author

sicaboy commented Oct 30, 2019

?

问号的意思是不清楚我的描述吗?假设我初始状态需要隐藏一个text field 直到某个switch为On。在打开这个编辑页面的时候它就应该要判断一次switch的状态是开还是关。

现在的功能只支持当我点击switch的时候 他才能判断on off 来隐藏那个text field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants