2

I have a page using HTML 5 drag and drop elements. When dropped into a container (div) it calls an ajax function

function drop(containerId, e) {

  var id = event.dataTransfer.getData("id");

  console.log(id);

  $.ajax({
    url: "dataworker.php",
    type: "POST",
    data: {
      id: id,
      containerid: containerId,
    },
    success: function() {
      console.log('great success');
      window.location.reload()
      return true
    }
  });
}

function dragStart(e) {
  console.log(e);
  e.dataTransfer.setData("id", e.srcElement.id);
}

function allowDrop(e) {
  e.preventDefault();
}

Is there a way to load a popup that allows the user to select one of many (up to 5) options pulled from a database (preferably php friendly)? I am hoping to be able to have the user select that data and post it to a different page BEFORE completing the drag action. or have a function to undo the drag if the user does not select an option

Robert Dickey
  • 816
  • 14
  • 35
  • Of course there is, it has nothing to do with your drag and drop thing though. https://www.google.nl/search?q=javascript+popup&ie=utf-8&oe=utf-8&gws_rd=cr&ei=PdKwVpHHOYHUPMamr7gN – Glubus Feb 02 '16 at 15:59
  • I have done quite a bit of research on regular JS and Jquery popups, but I am unable to find an example of a popup with multiple selectable options. I.e I want to have a popup that lists 5-6 users from my user database, and they can select that persons name. which then i hope can post to another page. – Robert Dickey Feb 02 '16 at 16:03
  • Too little code, where is html. What is problem, how people check element (check boxes). If checkbox then see if it is checked or no. Do when people click an element set a hidden checkbox checked – Michael Feb 02 '16 at 16:08
  • 1
    You can use after your `success : function(data){` add `data` than you can display in a dialog : `$('
    '+ data +'
    ').dialog('open');` where `data` can be everything you want to display from your code.
    – Alex Feb 02 '16 at 16:09
  • 1
    Have a look here: http://stackoverflow.com/questions/19663555/bootstrap-3-how-to-load-content-in-modal-body-via-ajax – Alvin Bakker Feb 02 '16 at 16:38

0 Answers0