A
A
Aison2020-05-08 05:28:23
JavaScript
Aison, 2020-05-08 05:28:23

How to call a fancybox modal via a function?

Greetings to all-all-all in this castle. Guys, there is such a design

edit: function(id, news_id, type){
  $.post(dle_root + 'engine/ajax/controller.php?mod=user_upload', {id:id, news_id:news_id, action:'edit', url:type}, function(response){
    if( response == 'not' ) alert('Файла нету');
    else if(response == 'not_owner') alert('Файл вам не принадлежит');
    else{	
      
    $("body").append("<div id='trueModalEditFile' style='display:none'>"+response+" <button data-fancybox-close class='btn'>Close me</button></div>");
    
    }
  });
  },


<a data-fancybox="" data-src="#trueModalEditFile" data-modal="true" href="#" onclick="uFiles.edit('0', '0', '0'); return false;" class="btn" title="Редактировать">линк</a>


and there is fancybox , docs

how do I trigger a fancybox modal with +response+ content? when clicked, I just create what is here
$("body").append


I know that the solution is simple, but I'm not at all strong in js yet. thank you^^

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Froggyweb, 2020-05-08
@Aison

This is

$('body').append("<div id='edit-file-alert' title='Редактировать' style='display:none'>"+response+"</div>");

change to this
$.fancybox.open(response)
You can change the markup in the parameters
or just add to that line
$.fancybox.open("#edit-file-alert")
should also work. In the documentation it is in the methods

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question