Hello everyone. :)
I make a website, there is a news editor in the admin panel. When clicking on the news, a dialog box should appear with a form for editing the news.

$(".edit").click(function () { var elementId = $(this).parent().attr("rel"); $.get("/Admin/EditNews", { id: elementId }, function (data) { $(data).dialog({ modal: true, title: "Редактор новости", width: 580, height: 450 }); }); }); 

That is, the form is requested via get, and then placed in the dialog box. In fact, everything works correctly, except for one moment. For some reason FIVE dialog boxes appear. With the form only one, the remaining 4 only with the title. And to start editing the news, you must first close the first 4.)

What kind of bug is this?

  • Do you have a jquery object in data? I would venture to suggest that there are 5 divs and jquery parsing them) - Sh4dow
  • Let's see. ) - Eugene
  • hmm, data did return json. Returns yes, several divs. but not five, and all this in one common diva. the result is absolutely the same. - Eugene
  • Yes, it seems, it's about data. If you output something else, it works fine. It remains to find what is the reason. - Eugene

1 answer 1

Try this: (dab into the document div with id, say, myDialog, and return the text to data as usual)

 $.get("/Admin/EditNews", { id: elementId }, function (data) { $('#myDialog').html(data); $('#myDialog').dialog({ modal: true, title: "Редактор новости", width: 580, height: 450 }); }); 
  • That is necessary, thank you. By the way, the number of additional dialogues was equal to the number of <script> TAGs that were also in the data variable. :) - Eugene