2

I am having issues opening a modal with buttons using OpenModalDialogCommand. It says in the docs of that command, that it can take as it's 3rd param any Jquery UI option (from http://api.jqueryui.com/dialog/) and it works well, for width/height/class, but anything more advanced i hit a wall. I am trying to make a button but can't figure it out.

$response = new AjaxResponse();
$options = [
    'width' => '800',
    'height' => '300',
    'dialogClass' => 'no-close',
    'buttons' => [
      'text' => 'Proceed',
      'click' => 'function() {alert();}'
    ]
];

$response->addCommand(new OpenModalDialogCommand('Title', 'Body', $options));
return $response;

This returns a modal successfully, width is ok, height is ok, class is ok, but there is not button, i tried 3/4 variations of it with no luck.

~p.s. i know i can make a simple form with one button, and return that in the modal, but there has got to be a way to make this work.

1 Answer 1

1

Ok figured it out.

$options = [
    'dialogClass' => 'my-form',
    'buttons' => [
        'button1' => [
            'text' => 'Proceed',
            'id' => 'onClickDoSomething',
        ]
    ]
];

And then in the .js file just write a function which fires when clickcing on a selector with the id onClickDoSomething voila, it's working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.