Linking buttion to jQuery through service

Posted by Ruddy on Stack Overflow See other posts from Stack Overflow or by Ruddy
Published on 2013-11-01T09:50:35Z Indexed on 2013/11/01 9:53 UTC
Read the original article Hit count: 307

Filed under:
|
|
|
|

I have a small problem that should be very easy to overcome. For some reason I cant work this out. So the problem is I cannot get a button to link to some jquery. My set-up is as follows (showing the relevant code):

Default.aspx

jQuery:

function getContent() {
    var data = {
        numberID: 1
    };

    $.jsonAspNet("ContentService.asmx", "GetContent", data,

    function (result) {
        $('#content').html(result);
    });
}

jQuery(document).ready(function () {
    getContent();
}

HTML:

<div id="content"></div>

ContentService.vb

Public Function GetContent(number As Integer) As String
        Dim sb = New StringBuilder

        sb.AppendLine("<table>")
        sb.AppendLine("<tr>")
        sb.AppendLine("<td class='ui-widget-header ui-corner-all'>Number</td>")
        sb.AppendLine("</tr>")
        sb.AppendLine("<tr>")
        sb.AppendLine("<td>" & number & "</td>")
        sb.AppendLine("<td><a href='#' id='test' class='fg-button ui-state-default ui-corner-all'><img src='" & Context.Request.ApplicationPath & "/images/spacer.gif' class='ui-icon ui-icon-pencil' /></a></td>")
        sb.AppendLine("</tr>")        
        sb.AppendLine("</table>")

        Return sb.ToString
    End Function

So that's the basics of what I have everything works but I'm not sure how to get the button (id='test') to get linked to some jQuery. I want it to be pressed and bring up a popup.

I have tried to put the jQuery on default.aspx but this doesn't seem to work unless the button is place in the HTML on that page.

$('#test').unbind('click').click(function () {
    alert('Working');
});

I'm sure this is easy to be able to do but I have been trying for a while and cannot seem to get it to work.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery