JQueryUI 将动态选择器传递给对话框

发布于 2024-10-11 21:26:09 字数 2865 浏览 1 评论 0原文

好的,当用户单击与记录相关的“添加”时,“添加”应该获取并使用与该记录相关的 DIV ID。我非常接近让它工作,但我只需要动态传递选择器。

那么你将如何动态地传递你的选择器呢?

<tr>
    <td>1/1/0001</td>
    <td>SOME FName</td>
    <td>SOME LNAME</td>
    <td>SKIN TW</td>
    <td>SOMEID</td>
    <td>1/7/2009</td><td>Graph Trend View <a href="#" id="dialog_3333333" class="ui-state-default ui-corner-all">Add</a></td>
    <td class="hide-cell">
    <!-- ui-dialog -->
   <div id="dialog_3333333_message" title="3333333 THOMAS LNAME">
    <p>3333333 THOMAS LNAME, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
   </div>            
    </td>
</tr>

    <tr>
        <td>6/21/2010</td>
        <td>EMERY</td>
        <td>LNAMED</td>
        <td>RAND E</td>
        <td>77777777777</td>
        <td>1/7/2009</td><td>Graph Trend View <a href="#" id="dialog_77777777777" class="ui-state-default ui-corner-all">Add</a></td>
        <td class="hide-cell">
        <!-- ui-dialog -->
       <div id="dialog_77777777777_message" title="77777777777 EMERY RANDOLPH">
        <p>77777777777 EMERY LNAME, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
       </div>            
        </td>
    </tr>

我已经非常接近解决方案,但无法克服这个障碍?

    $(function() {

      // Dialog
      **// This is where the dynamic selector needs to be passed in**
    $('#dialog_33333333_message').dialog({
        autoOpen: false,
        resizable: false,
        height: 260,
        modal: true,
        width: 240,
        buttons: {
          "Compare Carriers": function() {
            $(this).dialog("close");
          },
          "Save": function() {
            $(this).dialog("close");
          }
        }
      });

      // Dialog Link
      $('.ui-state-default').click(function() {

   var target = $(this).attr("id");   

      alert(target);

   $('#' + target + '_message').dialog('open');
        return false;
      });

      //hover states on the static widgets
      $('.ui-state-default').hover(
         function() { $(this).addClass('ui-state-hover'); },
         function() { $(this).removeClass('ui-state-hover'); }
        );
    });

这就是我所说的“我有多接近”的意思。 http://tinypic.com/r/2hs2o0i/7 转到图片,我要新发布图片

Ok so when a user clicks on Add as it relates to a record the Add is suppose to obtain and us the DIV ID related to the record. I'm pretty close to getting it to work but I just need to pass in the selector dynamically.

How would you pass in your selector dynamically though?

<tr>
    <td>1/1/0001</td>
    <td>SOME FName</td>
    <td>SOME LNAME</td>
    <td>SKIN TW</td>
    <td>SOMEID</td>
    <td>1/7/2009</td><td>Graph Trend View <a href="#" id="dialog_3333333" class="ui-state-default ui-corner-all">Add</a></td>
    <td class="hide-cell">
    <!-- ui-dialog -->
   <div id="dialog_3333333_message" title="3333333 THOMAS LNAME">
    <p>3333333 THOMAS LNAME, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
   </div>            
    </td>
</tr>

    <tr>
        <td>6/21/2010</td>
        <td>EMERY</td>
        <td>LNAMED</td>
        <td>RAND E</td>
        <td>77777777777</td>
        <td>1/7/2009</td><td>Graph Trend View <a href="#" id="dialog_77777777777" class="ui-state-default ui-corner-all">Add</a></td>
        <td class="hide-cell">
        <!-- ui-dialog -->
       <div id="dialog_77777777777_message" title="77777777777 EMERY RANDOLPH">
        <p>77777777777 EMERY LNAME, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
       </div>            
        </td>
    </tr>

I'm pretty close to a solution but can't get passed this obstacle?

    $(function() {

      // Dialog
      **// This is where the dynamic selector needs to be passed in**
    $('#dialog_33333333_message').dialog({
        autoOpen: false,
        resizable: false,
        height: 260,
        modal: true,
        width: 240,
        buttons: {
          "Compare Carriers": function() {
            $(this).dialog("close");
          },
          "Save": function() {
            $(this).dialog("close");
          }
        }
      });

      // Dialog Link
      $('.ui-state-default').click(function() {

   var target = $(this).attr("id");   

      alert(target);

   $('#' + target + '_message').dialog('open');
        return false;
      });

      //hover states on the static widgets
      $('.ui-state-default').hover(
         function() { $(this).addClass('ui-state-hover'); },
         function() { $(this).removeClass('ui-state-hover'); }
        );
    });

Here is what I mean by how close I am.
http://tinypic.com/r/2hs2o0i/7 Go to image, i'm to new to post image

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

百善笑为先 2024-10-18 21:26:09

您可以使用反映 div 对话框模式的选择器($('div[id^="dialog_").dialog()) 并按如下方式使用它:

$(function () { 
    $('div[id^="dialog_").dialog({
        autoOpen: false,
        resizable: false,
        height: 260,
        modal: true,
        width: 240,
        buttons: {
            "Compare Carriers": function () {
                $(this).dialog("close");
            },
            "Save": function () {
                $(this).dialog("close");
            }
        }
    }); // Dialog Link      
    $('.ui-state-default').click(function () {
        var target = $(this).attr("id");
        alert(target);
        $('#' + target + '_message').dialog('open');
        return false;
    });
    //hover states on the static widgets    
    $('.ui-state-default').hover(function () {
        $(this).addClass('ui-state-hover');
    }, function () {
        $(this).removeClass('ui-state-hover');
    });
});

You can use a selector which reflects the pattern that the div dialog($('div[id^="dialog_").dialog()) have and use it as below:

$(function () { 
    $('div[id^="dialog_").dialog({
        autoOpen: false,
        resizable: false,
        height: 260,
        modal: true,
        width: 240,
        buttons: {
            "Compare Carriers": function () {
                $(this).dialog("close");
            },
            "Save": function () {
                $(this).dialog("close");
            }
        }
    }); // Dialog Link      
    $('.ui-state-default').click(function () {
        var target = $(this).attr("id");
        alert(target);
        $('#' + target + '_message').dialog('open');
        return false;
    });
    //hover states on the static widgets    
    $('.ui-state-default').hover(function () {
        $(this).addClass('ui-state-hover');
    }, function () {
        $(this).removeClass('ui-state-hover');
    });
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文