We help IT Professionals succeed at work.

Jquery UI dialog multi use

This going back to my previous post http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_27426107.html?cid=748#a37070296.

Now I need to reuse the same code But the user clicked on the different link=. So basically working like a picker.

But the challange is nee to return the results back depends which link was clicked
Comment
Watch Question

IT Expert
CERTIFIED EXPERT
Top Expert 2009
Commented:
$(function() {
    $(".linkClick").each("click", function(event){
      event.preventDefault();
      var linkId = $(this).attr("id");
        $( "#dialog-confirm" ).dialog({
            resizable: false,
            height:340,
            modal: true,
            buttons: {
              "Show all items": function() {
                var result ="";
                $(this).find("select").each(function() {
                  result+=$(this).attr("name") + ': '+ $(this).val()+"<br/>";
                });
                $("#resultDiv"+linkId).html(result);
                $(this).dialog("close");
               },
               Cancel: function() {
                  $( this ).dialog( "close" );
               }
            }
        });
    });
});

<a href="..." ID="link1">Click</a>

<a href="..." ID="link2">Click</a>

<div id="resultDivlink1">Result for link 1</a>
<div id="resultDivlink2">Result for link 2</a>

Explore More ContentExplore courses, solutions, and other research materials related to this topic.