Possible Duplicate:
How to load wp_editor() through AJAX/jQuery
我知道之前有人问过这个问题,但没有得到充分、准确或描述性的回答。我知道如何在页面加载时加载wp\\U编辑器,如下所示:
<?php wp_editor( $content, \'bio\', $settings = array() ); ?>
但当通过ajax加载编辑器时,这不起作用。
我的插件加载足球运动员列表。单击播放器时,页面上的包装器div将替换为该特定播放器的数据。其中一部分需要是wp\\u editor的实例。
包装器div替换为以下表单。表单中的最后一行需要加载wp\\U编辑器。
此jQuery将“tfb\\u replace”div替换为响应,在本例中,响应是一个表单。
$.post(ajaxurl, data, function(response) {
$(\'.tfb_replace\').html(response);
});
以下是表格:
<form method="POST" action="" name="edit_player_form" enctype="multipart/form-data">
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="player_pic">Profile Image</label></th>
<td><input name="player_pic" value="<?php echo $object->player_pic; ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="player_height">Height</label></th>
<td><input name="player_height" value="<?php echo $object->player_height; ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="player_weight">Weight</label></th>
<td><input name="player_weight" value="<?php echo $object->player_weight; ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="player_year">Years in School</label></th>
<td><input name="player_year" value="<?php echo $object->player_year; ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="player_position">Category</label></th>
<td>
<select name="player_cat">
<option value="<?php echo $object->player_cat; ?>"><?php echo $object->player_cat; ?></option>
<option value="Mayor">Mayor</option>
<option value="Intermedia">Intermedia</option>
<option value="Juvenil">Juvenil</option>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="player_year">Bio</label></th>
<td><!-- wp_editor would load here --></td>
</tr>
</table>
<br/>
<input type="button" name="edit" value="Save Edits" class="button-primary" />
<input type="button" name="remove" value="Remove Player" class="button-primary" />
<input type="hidden" name="player_id" value="<?php echo $object->id; ?>" />
</form>