webdad3
webdad3

Reputation: 9080

Building HTML passing it in as XML and also using javascript?

This project I'm working on is building large amounts of HTML into a string and then putting it an XML string.

Then once that XML is fully built it is being saved into a hidden input form element. Then it is being passed to a javascript function which then parses that xml string.

The javascript function applies the $.parseXML to the value that was in the hidden input variable.

For the most part everything is working, however, there are also some javascript calls in that HTML string (i.e onclick).

When I look at the HTML string in Firebug the onclick event looks like this:

onclick="lbRowClick(this,ptObj_listbox0, 0);"

The problem I am having is right now the lbRowClick function is never firing. I imagine that I will also have an issue with the second parameter not having quotes around it as well (every time I put quotes around it I get an XML error).

I've been looking at this for awhile and I'm not sure which way to go. Any advice would be helpful.

Upvotes: 3

Views: 63

Answers (2)

Jonathan Lonowski
Jonathan Lonowski

Reputation: 123453

I imagine that I will also have an issue with the second parameter not having quotes around it as well (every time I put quotes around it I get an XML error).

If the onclick block has a syntax error in it, it won't execute and lbRowClick won't be called. If the 2nd parameter should be a string, try using single-quotes:

onclick="lbRowClick(this, 'ptObj_listbox0', 0);"

If that results in an XML error, try using ' for them:

onclick="lbRowClick(this, 'ptObj_listbox0', 0);"

Upvotes: 1

Robert Harvey
Robert Harvey

Reputation: 180787

If you can use jQuery, you might try using Live(), and see if it will pick up the late bindings in the HTML string.

Upvotes: 0

Related Questions