diff --git a/include/ajax.forms.php b/include/ajax.forms.php index 8044fafc32c7b1d9e77ee93f341d14903627d5f4..e53b91348a4d47b3a0b0bc44b001051f292f22d4 100644 --- a/include/ajax.forms.php +++ b/include/ajax.forms.php @@ -24,8 +24,18 @@ class DynamicFormsAjaxAPI extends AjaxController { $_SESSION[':form-data'] = array_merge($_SESSION[':form-data'], $_GET); } - if ($form = $topic->getForm()) + if ($form = $topic->getForm()) { + ob_start(); $form->getForm($_SESSION[':form-data'])->render(!$client); + $html = ob_get_clean(); + ob_start(); + print $form->getMedia(); + $media = ob_get_clean(); + } + return $this->encode(array( + 'media' => $media, + 'html' => $html, + )); } function getClientFormsForHelpTopic($topic_id) { diff --git a/include/client/open.inc.php b/include/client/open.inc.php index 26df0a5a367816f51cb8d3eeb969229bd39200aa..821aa6ef9cc8661e5126b070dc5d35fedc09d1df 100644 --- a/include/client/open.inc.php +++ b/include/client/open.inc.php @@ -34,9 +34,16 @@ if ($info['topicId'] && ($topic=Topic::lookup($info['topicId']))) { <td> <select id="topicId" name="topicId" onchange="javascript: var data = $(':input[name]', '#dynamic-form').serialize(); - $('#dynamic-form').load( - 'ajax.php/form/help-topic/' + this.value, data); - "> + $.ajax( + 'ajax.php/form/help-topic/' + this.value, + { + data: data, + dataType: 'json', + success: function(json) { + $('#dynamic-form').empty().append(json.html); + $(document.head).append(json.media); + } + });"> <option value="" selected="selected">— <?php echo __('Select a Help Topic');?> —</option> <?php if($topics=Topic::getPublicHelpTopics()) { diff --git a/include/staff/templates/dynamic-form.tmpl.php b/include/staff/templates/dynamic-form.tmpl.php index 8ed99010089804b4a63f513b238c1ef50a56719c..3987d9ee0ab9582db3fbcd57d669621477da6846 100644 --- a/include/staff/templates/dynamic-form.tmpl.php +++ b/include/staff/templates/dynamic-form.tmpl.php @@ -7,8 +7,6 @@ if (isset($options['entry']) && $options['mode'] == 'edit' ) return; -print $form->getMedia(); - if (isset($options['entry']) && $options['mode'] == 'edit') { ?> <tbody> <?php } ?> diff --git a/include/staff/ticket-edit.inc.php b/include/staff/ticket-edit.inc.php index 96d1abe6fc943457bf67cbfd3459582dd5b0da2c..2001e28505a525d15f0244f8d809c0e88d33bb8a 100644 --- a/include/staff/ticket-edit.inc.php +++ b/include/staff/ticket-edit.inc.php @@ -134,6 +134,7 @@ if ($_POST) <?php if ($forms) foreach ($forms as $form) { $form->render(true, false, array('mode'=>'edit','width'=>160,'entry'=>$form)); + print $form->getForm()->getMedia(); } ?> </table> <table class="form_table" width="940" border="0" cellspacing="0" cellpadding="2"> diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index 3c8b8f2421ee1840c2ddae3e2574abb4d387c1b0..39acb0864519519c278c7c4d28771476a4042c20 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -132,9 +132,16 @@ if ($_POST) <td> <select name="topicId" onchange="javascript: var data = $(':input[name]', '#dynamic-form').serialize(); - $('#dynamic-form').load( - 'ajax.php/form/help-topic/' + this.value, data); - "> + $.ajax( + 'ajax.php/form/help-topic/' + this.value, + { + data: data, + dataType: 'json', + success: function(json) { + $('#dynamic-form').empty().append(json.html); + $(document.head).append(json.media); + } + });"> <?php if ($topics=Topic::getHelpTopics()) { if (count($topics) == 1) @@ -252,6 +259,7 @@ if ($_POST) <tbody id="dynamic-form"> <?php if ($form) { + print $form->getForm()->getMedia(); include(STAFFINC_DIR . 'templates/dynamic-form.tmpl.php'); } ?>