Close a Modal with button ?

Hi,

I'm trying to close a modal not with the [x] on the bottom right but with a button placed on the modal.

My code is the following :

<b:modal id="modal1">
   <b:button>
      <e:handler event="click">
         <c:create destination="id('X')">
            ... action
         </c:create>
         var modal = bb.document.getElementById('modal1');
         modal.close();
      </e:handler>
   Close
   </b:button>
</b:modal>

This code doesn't work.
Have you got some similar example ?
Thanks by advance.

Modal close

Try

bb.document.getElementById('modal1').setAttribute('open',false);

Modal close

Thks Joop, but this try doesn't work at all.

Modal close

Copy of what works for me, perhaps it'll help.

                <b:modal label="Error" for=".." id="alertwin" dragConstraint=".." resizeConstraint="..">
                        <div style="font-size:150%;">Please select an order first</div>
                        <div style="margin-left:100px;; height:20px;">
                        <b:button>OK
                                <e:handler event="click" type="application/javascript"><![CDATA[
                                        bb.document.getElementById('alertwin').setAttribute('open',false);
                                        ]]>
                                </e:handler>
                        </b:button>
                        </div>
                </b:modal>

Close modal

Stumbled on another one i use somewhere else

<e:call method="close" with="id('modal1')" />

Close modal

Thanks a lot, This work very fine.

My problem was that I integrated at the same time in the handler, backbase code and javascript and it doesn't like. So with your solution I manage now to use only backbase code.

Thanks you.

laurene