Close Modal Window per JS-Event

mudshark79

Member
Hello Forum!

After tinkering around with several approaches for one specific challenge I think I'm on the rigth path but I'm stuck on the last bit.

The Idea: I have a (repeated) list which contains text-area elements. I want to make the content of this text-area elements simliar to what the hover-text function does but without the limitations of the hover text especially when it comes to repeated lists.

The approach (after trying different hings): I open up a view-version of the form in question in a modal window using indivdual Javascript in the list - which also provides maximum flexibility over a simple text-hover. I got an working version put together quite fast: I trigger a window-class event with a jquery mouseover. (This sample is missing the code for loading a different row-id based on the actual table-cell the mouse moves over, but this will be added later on).

I want to close the window on mouseout. I sucessfully destroyed the div using jquery but this leaves the window-class unusable. It only fires again if closed properly, it seems. What's the proper function-call for the mouseout-event ?:

Code:
requirejs(['fab/fabrik'], function () {
 
var repeat_list = jQuery( '.verlauf___repeatview_button' );
 
    jQuery( repeat_list ).mouseover(function(){
        Fabrik.getWindow({id:'uniqueid', 'loadMethod': 'iframe', 'contentURL':'index.php?option=com_fabrik&view=details&formid=35&rowid=7&tmpl=component', 'title': 'window title'});
        }).mouseout(function(){
 
      // This was the part I was looking for:
       delete(Fabrik.Windows['uniqueid']);
       jQuery('#uniqueid').remove();
    });
 
 
});

the closest I got (without getting an idea why this doesn't work) was trying to use jquery .trigger("click") on the .CloseFabWin of the modal window. After extensive forum and web research and even trying to understand the source I found this thread :

http://fabrikar.com/forums/index.php?threads/form-in-modal-box.37407/page-2

that talks about the same thing and Rob states, that the closing-call has to be fired from inside the modal box?

So is there no way to close the popup with a event form the "surrounding"-page?

Help is greatly appreciated :( .

Regards,

Matthias
 
:) got it!:


Code:
delete(Fabrik.Windows['uniqueid']);
jQuery('#uniqueid').remove();

Took a 2nd Look at the code and found out that "delete" kind of resets the windows-class which makes it reusable. Then I just had to combine it with the jQuery that I already found working. It's important to do the jQuery remove after the delete because otherwise the delete won't reset the windows-class and a new Popup won't be triggered. Maybe this is all quite obvious for someone who is really inside JS for a long time but always a hard time for me. Quite proud now that I found it by looking it up on github.
Rejoice and have a nice Weekend - my job for this week seems pretty much done :D.

Regards,

Matthias
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top