Revealing a Modal in Foundation 4

前端 未结 4 1296
温柔的废话
温柔的废话 2021-01-15 03:24

How do you Reveal a modal programmatically in Foundation 4?

In Foundation 3 we had the easy to use reveal() method.

What can you use in Foundation 4? Please

4条回答
  •  被撕碎了的回忆
    2021-01-15 03:39

    Unfortunately, in Foundation 4 you must have this trigger link to open a modal =/ Unfortunately not because you'll have to write a lot more code (thats not true), but because this implementation isnt, let's say, pretty.

    My code for the modal:

    
    
    
    

    JS function to open and put some content into the modal

    function openModal(url,params,text){
    
    // If @url is not empty then we change the #modalContent value with the @url value
    if(url !== '')
    {
        ajaxLoad('#modalContent',url,params);
    }
    // If @text is not empty then we change the #modalContent value with the @text value
    else if(text !== '')
    {
        $('#modalContent').html(text);
    }
    
    // If both @url and @text are empty, then the #modalContent remains unchanged. 
    // Now we just show de modal with the changed (or not) content
    $('a.reveal-link').trigger('click'); }
    

    Hope it helps!

提交回复
热议问题