1

jqueryを使用してフォームを作成しました。$('#Form')。append('');を使用するとすぐに 新しく追加された要素は、テーマが設定されていないか、PHPを使用して挿入したときと同じようには見えません。

明確にするために:

phpが追加されました:Jquery Mobile Style

Jqueryが動的に追加されました:通常のフォームスタイル。

どうすればパスを購入できますか?

======アドオン======わかりました、これがコードです

この関数はブロックを追加します:

function addItem(section){
    if(itemcounter[section]>1){
        $('table#deductionItemContent'+section+' tr:last').after('<tr id="deductionItemContentRow'+section+'_'+itemcounter[section]+'1"></tr>');
        $('table#deductionItemContent'+section+' tr:last').after('<tr id="deductionItemContentRow'+section+'_'+itemcounter[section]+'2"></tr>');
        $('table#deductionItemContent'+section+' tr:last').after('<tr id="deductionItemContentRow'+section+'_'+itemcounter[section]+'3"></tr>');
    }else{
        $('#deductionItemContent'+section).append('<tr id="deductionItemContentRow'+section+'_'+itemcounter[section]+'1"></tr>');
        $('#deductionItemContent'+section).append('<tr id="deductionItemContentRow'+section+'_'+itemcounter[section]+'2"></tr>');
        $('#deductionItemContent'+section).append('<tr id="deductionItemContentRow'+section+'_'+itemcounter[section]+'3"></tr>');
    }

    $('#deductionItemContent'+section).append('<tr id="deductionItemContentRow'+section+'_'+itemcounter[section]+'1"></tr>');
    $('#deductionItemContent'+section).append('<tr id="deductionItemContentRow'+section+'_'+itemcounter[section]+'2"></tr>');
    $('#deductionItemContent'+section).append('<tr id="deductionItemContentRow'+section+'_'+itemcounter[section]+'3"></tr>');
    $('#deductionItemContentRow'+section+'_'+itemcounter[section]+'1').append('<td id="deductionItemContent'+section+'El'+itemcounter[section]+'"></td>');
    $('#deductionItemContent'+section+'El'+itemcounter[section]).append('<div class="type-select"><label for="nu_item_'+section+'_'+itemcounter[section]+'">{/literal}{translate text="application_reports_plate5_item"}{literal}'+itemcounter[section]+'</label><select onchange="updateForm('+section+');" id="nu_item_'+section+'_'+itemcounter[section]+'" name="nu_item_'+section+'_'+itemcounter[section]+'"></select></div>')
    $('#nu_item_'+section+'_'+itemcounter[section]).append('<option value="main">{/literal}{translate text="application_reports_plate5_item_main"}{literal}</option>');
    $('#nu_item_'+section+'_'+itemcounter[section]).append('<option value="aux">{/literal}{translate text="application_reports_plate5_item_aux"}{literal}</option>');
    $('#nu_item_'+section+'_'+itemcounter[section]).append('<option value="jib">{/literal}{translate text="application_reports_plate5_jib"}{literal}</option>');
    $('#nu_item_'+section+'_'+itemcounter[section]).append('<option value="rope">{/literal}{translate text="application_reports_plate5_rope"}{literal}</option>');
    $('#nu_item_'+section+'_'+itemcounter[section]).append('<option value="underhookdevice">{/literal}{translate text="application_reports_plate5_underhookdevice"}{literal}</option>');
    $('#nu_item_'+section+'_'+itemcounter[section]).append('<option value="rigging">{/literal}{translate text="application_reports_plate5_rigging"}{literal}</option>');
    $('#nu_item_'+section+'_'+itemcounter[section]).append('<option value="none">{/literal}{translate text="application_reports_plate5_none"}{literal}</option>');
    $('#deductionItemContentRow'+section+'_'+itemcounter[section]+'2').append('<td id="deductionItemContent'+section+'E2'+itemcounter[section]+'"></td>');
    $('#deductionItemContent'+section+'E2'+itemcounter[section]).append('<div class="type-select"><label for="nu_status_'+section+'_'+itemcounter[section]+'">{/literal}{translate text="application_reports_plate5_itemstatus"}{literal} '+'</label><select onchange="updateForm('+section+');" id="nu_status_'+section+'_'+itemcounter[section]+'" name="nu_status_'+section+'_'+itemcounter[section]+'"></select></div>')
    $('#nu_status_'+section+'_'+itemcounter[section]).append('<option value="stowed">{/literal}{translate text="application_reports_plate5_item_stowed"}{literal}</option>');
    $('#nu_status_'+section+'_'+itemcounter[section]).append('<option value="erected">{/literal}{translate text="application_reports_plate5_item_erected"}{literal}</option>');
    $('#nu_status_'+section+'_'+itemcounter[section]).append('<option value="inservice">{/literal}{translate text="application_reports_plate5_item_inservice"}{literal}</option>');
    $('#nu_status_'+section+'_'+itemcounter[section]).append('<option value="none">{/literal}{translate text="application_reports_plate5_none"}{literal}</option>');
    $('#deductionItemContentRow'+section+'_'+itemcounter[section]+'3').append('<td id="deductionItemContent'+section+'E3'+itemcounter[section]+'"></td>');
    $('#deductionItemContent'+section+'E3'+itemcounter[section]).append('<div class="type-text"><label for="nu_deduction_'+section+'_'+itemcounter[section]+'">{/literal}{translate text="application_reports_plate5_deduction"}{literal}</label><input onkeyup="updateForm('+section+');" type="text" length="6" maxlength="6" id="nu_deduction_'+section+'_'+itemcounter[section]+'" name="nu_deduction_'+section+'_'+itemcounter[section]+'" /></div>');
    /**
     * Add Data to page 3
     */
    $('#weightMasterDataTable'+section).append('<tr id="weightMasterDataTableRow'+section+itemcounter[section]+'"></tr>');
    $('#weightMasterDataTableRow'+section+itemcounter[section]).append('<td id="weightMasterDataTableContent'+section+itemcounter[section]+'1"></td>');
    $('#weightMasterDataTableRow'+section+itemcounter[section]).append('<td id="weightMasterDataTableContent'+section+itemcounter[section]+'2"></td>');
    $('#weightMasterDataTableRow'+section+itemcounter[section]).append('<td id="weightMasterDataTableContent'+section+itemcounter[section]+'3">0</td>');
    $('#weightMasterDataTableRow'+section+itemcounter[section]).append('<td id="weightMasterDataTableContent'+section+itemcounter[section]+'4">0</td>');
    $('#weightMasterDataTableRow'+section+itemcounter[section]).append('<td id="weightMasterDataTableContent'+section+itemcounter[section]+'5">0</td>');
    /**
     * Add Radio Buttons
     */
    $('#weightMasterDataButtons'+section).append('<input type="radio" name="nu_masterbutton_'+section+'" id="nu_masterbutton_'+section+'_'+itemcounter[section]+'" value="'+itemcounter[section]+'" /><label for="nu_masterbutton_'+section+'_'+itemcounter[section]+'" >&nbsp;&nbsp;{/literal}{translate text="application_reports_plate5_item"}{literal} '+itemcounter[section]+'</label>');
    $('#weightMasterDataButtons'+section).append('<br />');
    /**
     * in the end update counter
     */
    itemcounter[section]++;
}

これに属するHTMLコードは次のようになります。

<tr>
    <td>
        <div id="tabs-2">
            <h4>deductions for loadtest 1</h4>
            <div id="deductions1">
                <a onclick="addItem(1);">+ Add item to deduction</a>
                <table id="deductionMaster1" class="tablecloth" width="100%" cellspacing="0" cellpadding="0" border="0">
                    <tbody>
                        <tr id="deductionMasterRow11">
                            <td>
                                <table id="deductionItemContent1" class="tablecloth" width="100%" cellspacing="0" cellpadding="0" border="0"></table>
                            </td>
                        </tr>
                        <tr id="deductionMasterRow12">
                            <td id="deductionMasterElement12">
                            total:
                            <b id="deductionValue1">0</b>
                            lbs
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </td>
</tr>

すべてが同じように反応するため、これはフォームのごく一部にすぎません。挿入されたフォーム要素がjqueryスタイルをテーマにしていることをブラウザに伝える必要があると思います。しかし、私はその方法がわかりません。

4

1 に答える 1

1

追加してみる

$('select').selectmenu();

jQueryスクリプトの最後に. <select> タグを処理する必要があります。それが成功した場合は、jquery mobile のドキュメントを参照して、ページに必要なその他のフォーム要素を処理する方法を確認してください。

于 2012-11-18T00:22:18.603 に答える