javascript - Adding a simple confirm/cancel dialog in jQuery 1.4.2 -
i have put clickable span every list item , works fine. moment invokes simple alert.
now add simple cancel/confirm dialog. each selection should call function.
here code (note alert span click invokes):
<%@ reference control="~/kpip/controls/multiupload.ascx" %> <%@ register src="~/kpip/controls/multiupload.ascx" tagname="multiupload" tagprefix="tetrada" %> <%@ page language="vb" autoeventwireup="false" codefile="entry.aspx.vb" inherits="kpip_entry" %> var barcodes = { <%# barcodearray %> } kpip.viewattachment = function (url) { $("#entryviewer").attr("src", "../viewer.aspx?image=" + url); } function resizeviewer() { $("#entryviewer").hide(); $("#attachments").hide(); $("#entryviewer").width($("#entryform").width() - 320 - 4); $("#entryviewer").height($("#entryform").height() - $("#header").height() - 4); $("#attachments").height($("#entryform").height() - $("#header").height() - 4); $("#attachments").show(); $("#entryviewer").show(); } $(function () { $.each(barcodes, function(key, value) { $("#barcodeslist").append("<li>" + key + "</li>"); }); deletebutton = $('<span />').addclass('deletebutton').text('delete'); $('ul#barcodeslist li').append(deletebutton); if ($("#barcodeslist").children().size() > 0) { $("#barcodeslist").after('<div id="barcodesshadow" class="cc_panelshadow"></div>'); } $("#barcodeslist > li").click(function () { $(this).children(".children").toggle(); $("#barcodeslist > li").removeclass("clicked"); $(this).addclass("clicked"); $("#selectedbarcode").val($(this).text()); var params = '{ barcode : "' + $(this).text() + '", path : "' + barcodes[$(this).text()] + '" }'; $.ajax({ type: "post", contenttype: "application/json; charset=utf-8", url: "entry.aspx/attach", datatype: "json", data: params, success: function () { $("#dummypostbackbutton").click(); }, error: function (request, status, error) { alert("error attaching barcode file."); } }); }); $("#barcodeslist > li > span").click(function(e) { e.stoppropagation(); var partxt = $(this).parent().clone().children().remove().end().text(); alert(partxt); }); $(window).bind("resize", function () { settimeout(function () { resizeviewer(); }, 10); }); settimeout(function () { resizeviewer(); }, 10); $("#barcodeslist > li").each(function () { if ($(this).text() != $("#selectedbarcode").val()) { return; } $(this).addclass("clicked"); }); }); </script> </head> <body> <form id="entryform" runat="server"> <div id="header" class="contentheader"> <asp:label runat="server" cssclass="contentheaderlabel" text="<%$ resources: header.text %>"/> </div> <div id="attachments"> <asp:label class="tetradagrouplabel" runat="server" text="<%$ resources: attachmentspanel.text %>" /> <tetrada:multiupload id="upload" runat="server" /> <asp:panel id="barcodeslistpanel" runat="server"> <asp:label class="tetradagrouplabel" runat="server" text="<%$ resources: barcodespanel.text %>" /> <ul id="barcodeslist"></ul> </asp:panel> <asp:hiddenfield id="selectedbarcode" runat="server" /> <asp:button id="dummypostbackbutton" runat="server" causesvalidation="false" /> </div> <iframe id="entryviewer" frameborder="0" runat="server"></iframe> </form> </body> </html>
i tried putting dialog in several places , opening in click event, nothing happens. can 1 please me out here?
best regards, no9.
if want add confirm dialog box code
it looks like
var choice = confirm("are sure?");
and validates if user clicks yes || no
if(choice == true) { //then here }
hope helps..
Comments
Post a Comment