ユーザーは列からサービスをクリックする必要があります。関数内のコードが大きすぎて専有的であり、変更できません。コードは正常に機能しています。これは重要な部分です。
this.addDeliveredServicePressed = function() {
//big code ...............................
//Important bit ORIGINAL
var rowCallback = function(nRow, aData, iDisplayIndex) {
/* Set onclick action */
nRow.onclick = deliveredServiceClicked;
return nRow;
//Follow up code...
}
};
行をクリックすると、deliveredServiceClicked 関数が呼び出され、何かが実行され、それが返され、フォローアップ コードがテーブルを作成します。
Jqueryプラグインを使用してrowCallback関数でJquery関数を使用しました。問題は、ボスが「ボックス」をWebページ上の他のボックスのcssスタイルと「正確に」一致させたいことです。だから私がしたことは、nRow.onclick にある種の「ブリッジ」を作成し、YES/NO オプションで HTML DIV を呼び出すことでした (既に作成された CSS クラスを使用するためにこれを行いました)、No オプションはクローズ関数です。 YES 関数。グローバル変数を変更する関数を実行して、nRow.onclick=deliveredServiceClicked; を検証して実行する必要があります。
これは、変更後の主要な機能です。
this.addDeliveredServicePressed = function() {
var rowCallback = function(nRow, aData, iDisplayIndex) {
/* Set onclick action */
if (confirmedglobal==1){
alert("serviceclicked");
nRow.onclick = deliveredServiceClicked;
confirmedglobal=0;
//This confirmedglobal=0, puts the global back to 0 so after the first YES it resets it back to 0, so it keeps asking.
return nRow;
}else if (confirmedglobal==0){
//This is the redirect to the HTML dialogue, using some util
nRow.onclick = ConfirmService;
}
};
これはYES onclickの私の機能です
this.Confirmed = function (){
confirmedglobal = 1;
addDeliveredServicePressed();
//diag box close util to be added, not now
}
したがって、この関数を再開するには、私の計画では、グローバルを 1 にしてから、メイン関数である関数 addDeliveredServicePressed を最初から実行して、必要なマークを更新する必要があります。現在行っていることは、グローバルを 1 に設定することですが、addDeliver にはなりません....グローバルを変更しますが、何も起こらず、閉じて再度開くと、YES NO を要求しなくなりますが、追加されますテーブルを完全にうまく構築します。
だから私の質問はこれです、なぜ addDeliveredServicePressed(); は 私の確認済み関数が実行されていない場合、これに対して他にどのようなアプローチを使用しますか??、多くのオプションについて考えましたが、グローバル変数と if を使用して、より良い解決策としてグローバル変数が最適なオプションではありません。
いずれにせよ、私はjsの初心者です。だから、私はおそらく何も見逃していないわけではない
質問へのフォローアップ
同じjsではこれだけです
deliveredServicesTable = $('#deliveredServices').dataTable( {
"bDestroy": true,
"oLanguage": {
"sEmptyTable": translate.msg("info.no.delivered.services"),
"sInfo": "",
"sInfoEmpty": "",
"sZeroRecords": ""
},
"bFilter": false,
"fnRowCallback": rowCallback,
"fnHeaderCallback": headerCallback,
"bLengthChange": false,
"bProcessing": true,
"bPaginate": false,
"aoColumns": columns,
"sScrollX": "95%",
"sScrollY": "158px",
"aaData": (sessvars.state.visit != null &&
sessvars.state.visit.currentVisitService != null &&
sessvars.state.visit.currentVisitService.visitDeliveredServices !== null ?
sessvars.state.visit.currentVisitService.visitDeliveredServices : null)
});
$(window).bind('resize', function () {
deliveredServicesTable.fnAdjustColumnSizing();
} );
}
「jquery.datatables.js」というファイルには、関数で使用するためのjqueryプラグインのようなものがありますが、そこからは何も必要ないと思います.35k行のコードのようで、複数の関数があります
/**
* This function allows you to 'post process' each row after it have been
* generated for each table draw, but before it is rendered on screen. This
* function might be used for setting the row class name etc.
* @type function
* @param {node} nRow "TR" element for the current row
* @param {array} aData Raw data array for this row
* @param {int} iDisplayIndex The display index for the current table draw
* @param {int} iDisplayIndexFull The index of the data in the full list of
* rows (after filtering)
* @dtopt Callbacks
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
* // Bold the grade for all 'A' grade browsers
* if ( aData[4] == "A" )
* {
* $('td:eq(4)', nRow).html( '<b>A</b>' );
* }
* }
* } );
* } );
*/
"fnRowCallback": null,