フォームとsortable()リストがあり、ユーザーは事前に入力されたリストから空のULにドラッグできます。ユーザーは、必要なLIをこの空のULにドラッグします。ユーザーが入力して[送信]をクリックするテキストボックスがいくつかあるフォームもあります。
ajaxformでフォームデータを送信してflashdataセッションで表示することはできますが、allowed_fieldsデータを表示することはできません。(これはソート可能なリストです)。alert(serializedList);
実行すると要素のシリアル化されたリストが返されるため、シリアル化することはわかっています。
これは、ソート可能なリストを生成するためのJSです。
/**
* sortable ul items
*
* this is used for the add levels page to associate allowed_fields
* to a level.
*/
$('.block-list').sortable({
connectWith: '.block-list',
placeholder: 'placeholder'
});
これは、ajaxSubmitを処理するJSです。
/**
* showResponse(data)
* show the response if the form submission is successful
* @param {object} data object of message or success
* @return {null}
*/
function showResponse(data){
alert(serializedList);
if (data.errorStatus == 1){
$.jGrowl(data.message, { theme: 'error' });
}else{
$.jGrowl(data.message, { theme: 'success' });
}
}//end showResponse()
/** @type {Object} setup the options for the ajax submit forms. */
var submitOptions = {
success: showResponse,
beforeSubmit: function(){ serializedList = $("#allowed-fields-list").sortable('serialize'); },
dataType: 'json',
resetForm: true ,
data: { allowed_fields: serializedList }
};
$("#addlevel-form").ajaxForm(submitOptions);
これは、フォームデータを処理するコードイグナイター関数です。
public function addlevelprocess(){
$message = array(
'message' => 'Successfully Added The Level To The Database! WHOA!:'.$this->input->post(),
'errorStatus' => 0
);
$this->session->set_flashdata('post', $this->input->post());
echo json_encode($message);
}
フォームフィールドデータとsortables()データの両方を送信するようにajaxformを取得するにはどうすればよいですか。