Generate a <script> tag when replacing content with a $.post
When I'm replacing the content in the "results" div tag
I lose all my data in the <script> tag.
Inside the script tag I'm dynamically generating sliders for input fields
based on the result that I get back from another server.
Does anybody got any ideas?
Here is my doSubmit function
- function doSubmit(reload) {
$.post("request",$("#state_form").serialize(),function(data) {
var content = $(data).find('#results');
$("#results").replaceWith(content);
<%out.println(hoffmanUIControls.getSliderJavaScript(request.getParameter("jtc_group"), request.getHeader("User-Agent")));%>
var fieldName = $("#jtc_cursor_position").val();
setTimeout(function() { $("#" + fieldName).focus(); }, 10);
}, "text");
}
Here is what the page looks like when it first loads ...
- <div id="results">
- <script language="JavaScript">.....</script>
- <form id="state_form" action="request" method="POST" name="state_form">...</form>
- <form target="-1" action="request" method="POST" name="pdf_modified_form">...</form>
- <form target="-2" action="request" method="POST" name="pdf_custom_form">...</form>
- <div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">...</div>
- <table width="100%" cellspacing="2" cellpadding="2" border="0">
- </div>
Here is what it looks like after the replaceAll happens
-
<div id="results">
<form id="state_form" action="request" method="POST" name="state_form">...</form>
<form target="-1" action="request" method="POST" name="pdf_modified_form">
...</form>
<form target="-2" action="request" method="POST" name="pdf_custom_form">
...</form>
<div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">...</div>
<table width="100%" cellspacing="2" cellpadding="2" border="0">
</div>
I some how need to be able to generate a <script> tag and populate it with more javascript functions.