簡體   English   中英

jQuery對話框的可拖動功能不起作用

[英]jquery dialog box draggable feature not working

我有一個javascript文件,其中包含以下彈出查詢對話框div標簽的jquery代碼,其中帶有textarea和一個按鈕。 我想使此彈出窗口可拖動,但是即使使用了draggable:true功能並使用父div標簽啟用了可拖動功能,它也無法正常工作.....有什么建議嗎?

 $(".showDialog").click(__bind(function() {

    var element, dialogId, textareaHtml;

    dialogId = "" + this.namespace + "dialog";
    textareaHtml = "<textarea style=\"width: 564px; height: 242px;\" id=\"textareadialog\" name=\"description_dialog_textarea\">" + ($("#description").val()) + "</textarea><input readonly type=\"text\" class=\"counter\" name=\"counter\" size=\"4\" maxlength=\"4\" value=\"4000\">;
    $("<div id=\"" + dialogId + "\>").html(textareaHtml).dialog({
      autoOpen: true,
      title: "Description",
      modal: true,
      width: 625,
      height: 360,
      draggable: true,
      buttons: {
        save: __bind(function() {
          var val;
          val = $("#textareadialog").val();
          $("#description").val(val);
          $("#description_fake").html(val);
          $("#description_fake").attr("title", val);
          $('#' + dialogId).dialog("close");
          $('#' + dialogId).remove();
          this.makeDescriptionCluetips();
          return this.update();
        }, this)
      },
      close: function() {
        return $('#' + dialogId).remove();
      }
    });

它始終是更好地附上' ,而你有一個字符串單引號"雙引號,它的破解,以避免錯誤。

換線

textareaHtml = "<textarea style=\"width: 564px; height: 242px;\" id=\"textareadialog\" name=\"description_dialog_textarea\">" + ($("#description").val()) + "</textarea><input readonly type=\"text\" class=\"counter\" name=\"counter\" size=\"4\" maxlength=\"4\" value=\"4000\">;
$("<div id=\"" + dialogId + "\>").html(textareaHtml).dialog({

textareaHtml = '<textarea style="width: 564px; height: 242px;" id="textareadialog" name="description_dialog_textarea">'+$("#description").val()+'</textarea><input readonly type="text" class="counter" name="counter" size="4" maxlength="4" value="4000">';
$('<div id="'+dialogId+'">').html(textareaHtml).dialog({

而且,如果您說的是目標ID,則直接使用$("#"+dialogId)而不是$('<div id="'+dialogId+'">')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM