Guest User

Untitled

a guest
Jun 25th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function () {
  2.     $("#move_topic").click(function () {
  3.         $.getJSON(baseUrl + "/sections/json", function (sections) {
  4.             var sectionsSize = sections.length;
  5.             var str = '<b>Move topic</b><br/><select name="section_name" id="section_name" size="' + sectionsSize + '">';
  6.             $.each(sections, function (i, section) {
  7.                 str += '<option value="' + section.id + '">' + section.name + '</option>';
  8.             });
  9.             str += '</select>';
  10.             str += '<select name="branch_name" id="branch_name" size="' + sectionsSize + '">';
  11.             str += '<option value="' + 0 + '">&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</option>';
  12.             str += '</select>';
  13.             var branchId;
  14.             $.prompt(str, {
  15.                 buttons:{ Move:true, Cancel:false},
  16.                 loaded:function () {
  17.                     $("#section_name").change(function () {
  18.                         var sectionId = $(this).val();
  19.                         $.ajax({
  20.                             url:baseUrl + '/branches/json/' + sectionId,
  21.                             success:function (branches) {
  22.                                 $("#branch_name").children().remove();
  23.                                 $("#branch_name").append(getBranchHtml(branches));
  24.                             }
  25.                         });
  26.                     });
  27.                     $("#branch_name").change(function () {
  28.                         branchId = $(this).val();
  29.                     });
  30.                 },
  31.                 callback:function (value, message, form) {
  32.                     if (value != undefined && value) {
  33.                         $.post(baseUrl + '/topics/json/' + topicId, {"branchId":branchId});
  34.                     }
  35.                 }
  36.             });
  37.         });
  38.     });
  39. });
Add Comment
Please, Sign In to add comment