0

基本的に、「タブ付き」divのあるページがあり、ユーザーがタブの1つをクリックすると、そのdivに.htmlページがロードされます。とにかく、.load()javascript関数からロードされた新しいデータに対してJS関数を実行できるのではないかと思っていました。

これが新しいデータをロードする関数です。

    function switchAssetTabContent(tabContext, func, params) {
    $("#ctl00_ContentPlaceHolder1_Overview1_tcAssetAllocation_tpAssetClassPrimary").html('<table width="375px" height="auto" style="min-height: 100px; height: auto; width: 260px;"><tr><td align="center" valign="middle"><img src="/backoffice/Prospects/App360/images/spinwait.gif" /></td></tr></table>');
    var url = "pageFragments/overview/" + tabContext + ".html";
    $("#ctl00_ContentPlaceHolder1_Overview1_tcAssetAllocation_tpAssetClassPrimary").load( url +"?" + (new Date().getTime()), params, updateYesterday );
    }   

ロードされるデータは次のとおりです。

<div bgcolor="white" id="ctl00_ContentPlaceHolder1_Overview1_pnlAssetClassAllocation">
    <table cellspacing="0" cellpadding="0" style="width: 375px;" border="0">
    <tr><td
        valign="top"
        style="background-color: white vertical-align: top; width: 175px"
        id="ctl00_ContentPlaceHolder1_Overview1_tdAssetClassChart">
        <div bgcolor="white" style="padding:0" id="AssetClassChartControlDiv" class="chart">
        </div>
        </td>
      <td valign="top">

        <div id="ctl00_ContentPlaceHolder1_Overview1_pnlAssetClassLegend">

          <input type="hidden" value="" name="ctl00xContentPlaceHolder1xOverview1xuwgAssetClassChartLegend" id="ctl00_ContentPlaceHolder1_Overview1_uwgAssetClassChartLegend" />
          <table cellspacing="0" cellpadding="0" border="0" style="overflow: hidden; position: relative;" id="ctl00xContentPlaceHolder1xOverview1xuwgAssetClassChartLegend_main">
              <tr id="ctl00xContentPlaceHolder1xOverview1xuwgAssetClassChartLegend_mr">
                <td align="left" style="vertical-align: top;">
                    <div id="AssetClassChartControl_legend" class="legend">
                    </div>
                </td>
              </tr>
          </table>

        </div>

</td></tr>
</table>

</div>

そして、メインページにjs関数が記述されており、現在ロードされているhtml<div><span>sのIDを使用する情報を呼び出します。含まれているページに.js関数を配置できますか?js関数をタグ<head></head>の内外にのみ含めるべきだと思っただけ<body></body>です.....どんな助けでも大歓迎です。

4

1 に答える 1

1

関数を再実行するdocument.ready()場合は、名前付き関数にすることができます。

function myReadyFunction() { ... }

document.ready(myReadyFunction);

次に、呼び出し時にそれを使用できます.load()

$("#ctl00_ContentPlaceHolder1_Overview1_tcAssetAllocation_tpAssetClassPrimary").load( url +"?" + (new Date().getTime()), params, myReadyFunction );
于 2013-03-26T16:48:43.523 に答える