0

基本的に、私は2つのテーブルを並べて持っていて、あるテーブルから別のテーブルに行を切り替えていますが、それはうまくいきますが、毎回画像をロードしているようです。すでにロードされているが、あるテーブルから削除されて別のテーブルに追加されている同じイメージの再ロードを防ぐ方法はありますか?

function addRow(tableID, rowObject, i) {
  // Get a reference to the table
  var tableRef = document.getElementById(tableID);

  // Insert a row in the table at row index 0
  var newRow   = tableRef.insertRow(i);

  // Insert a cell in the row at index 0
  var newCell  = newRow.insertCell(0);

  // Append an object to the cell
  newCell.appendChild(rowObject);
}

function MoveCardToOtherSideOfTrade()
{
        var tableId = $(this).parents('table').attr('id');
        var cardId = $(this).parents('tr').attr('id');

        $card = document.getElementById(cardId);
        $(this).parent().parent().parent().remove();

        if( tableId == 'LeftSideTable' )
            addRow('RightSideTable', $card, 1);
        else if( tableId == 'RightSideTable' )
            addRow('LeftSideTable', $card, 1);

        // Since we had to remove the item from the DOM then re-add it to the other side
        // we now are forced to dynamically bind the action for all the javascript-using clickable links
        $('.deleteCardFromTradeButton').click(DeleteCardFromTrade);
        $('.moveCardToOtherSideOfTradeButton').click(MoveCardToOtherSideOfTrade);   
}


<table id='LeftSideTable'><tr valign='top'><td><input type=submit value='Update &#x2713;'></td><tr id='418' trade-from-user='ChumpMaster' trade-to-user='bthannan'><td>
                    <input type='text' name='q418' value='1' style='align: center;width: 20px; padding: 2px; border: 1px solid black'>

                    <input type='text' rows='2' cols='10' name='n418' id='course' autocomplete='off'  value="Breaking // Entering">

                    <b>$</b><input type='text' name='p418' value='0.74' style='align: center;width: 45px; padding: 2px; border: 1px solid black'>

                    <input type='hidden' name='i418' value='418'>
                     = <b>$</b>0.74     <font size='+1'><a class='deleteCardFromTradeButton'>X</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|<a class='moveCardToOtherSideOfTradeButton'>Switch Sides</a></font>

                    <object data="http://www.gatheryourmagic.com/wp-content/plugins/mtg-card-links/getter.php?n=Breaking // Entering" height=400><embed src='http://www.gatheryourmagic.com/wp-content/plugins/mtg-card-links/getter.php?n=Breaking // Entering' > </embed> Error: Embedded data could not be displayed. </object>
                    <textarea rows='2' cols='10' name='s418' style='align: center;width: 300px; padding: 2px; border: 1px solid black'></textarea>
                    <img src="http://ark42.com/mtg/pricehistory.php?s=Dragon's Maze&amp;c=Breaking // Entering&amp;f=0&amp;d=0&amp;p=1" width='261' height='125' alt=''><br>
                    Powered by <a href='http://www.ark42.com/mtg' target=_blank>http://www.ark42.com/mtg</a>
                    </td></tr><tr id='415' trade-from-user='ChumpMaster' trade-to-user='bthannan'><td>
                    <input type='text' name='q415' value='2' style='align: center;width: 20px; padding: 2px; border: 1px solid black'>

                    <input type='text' rows='2' cols='10' name='n415' id='course' autocomplete='off'  value="Sphinx's Revelation">

                    <b>$</b><input type='text' name='p415' value='23.00' style='align: center;width: 45px; padding: 2px; border: 1px solid black'>

                    <input type='hidden' name='i415' value='415'>
                     = <b>$</b>46     <font size='+1'><a class='deleteCardFromTradeButton'>X</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|<a class='moveCardToOtherSideOfTradeButton'>Switch Sides</a></font>

                    <object data="http://www.gatheryourmagic.com/wp-content/plugins/mtg-card-links/getter.php?n=Sphinx's Revelation" height=400><embed src='http://www.gatheryourmagic.com/wp-content/plugins/mtg-card-links/getter.php?n=Sphinx's Revelation' > </embed> Error: Embedded data could not be displayed. </object>
                    <textarea rows='2' cols='10' name='s415' style='align: center;width: 300px; padding: 2px; border: 1px solid black'></textarea>
                    <img src="http://ark42.com/mtg/pricehistory.php?s=Return to Ravnica&amp;c=Sphinx's Revelation&amp;f=0&amp;d=0&amp;p=1" width='261' height='125' alt=''><br>
                    Powered by <a href='http://www.ark42.com/mtg' target=_blank>http://www.ark42.com/mtg</a>
                    </td></tr><tr><td><input type=submit value='Update &#x2713;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Total = $46.74</b></td></table></td><td valign='top'><table id='RightSideTable'><tr><td><input type=submit value='Update &#x2713;'></td><tr id='417' trade-from-user='.ChumpMaster.' trade-to-user='.bthannan.'><td>
                        <input type='text' name='q417' value='1' style='align: center;width: 20px; padding: 2px; border: 1px solid black'>

                        <input type='text' rows='2' cols='10' name='n417' id='course' autocomplete='off'  value="Tarmogoyf">

                        <b>$</b><input type='text' name='p417' value='137.70' style='align: center;width: 45px; padding: 2px; border: 1px solid black'>

                        <input type='hidden' name='i417' value='417'>
                         = <b>$</b>137.7     <font size='+1'><a class='deleteCardFromTradeButton'>X</a></font>  

                        <object data="http://www.gatheryourmagic.com/wp-content/plugins/mtg-card-links/getter.php?n=Tarmogoyf" height=400><embed src='http://www.gatheryourmagic.com/wp-content/plugins/mtg-card-links/getter.php?n=Tarmogoyf'> </embed> Error: Embedded data could not be displayed. </object>
                        <textarea rows='2' cols='10' name='s417' style='align: center;width: 300px; padding: 2px; border: 1px solid black'></textarea>
                        <img src="http://ark42.com/mtg/pricehistory.php?s=Modern Masters&amp;c=Tarmogoyf&amp;f=0&amp;d=0&amp;p=1" width='261' height='125' alt=''><br>
                        Powered by <a href='http://www.ark42.com/mtg' target=_blank>http://www.ark42.com/mtg</a>
                        </td><td></td></tr><tr id='416' trade-from-user='.ChumpMaster.' trade-to-user='.bthannan.'><td>
                        <input type='text' name='q416' value='1' style='align: center;width: 20px; padding: 2px; border: 1px solid black'>

                        <input type='text' rows='2' cols='10' name='n416' id='course' autocomplete='off'  value="Sphinx's Revelation">

                        <b>$</b><input type='text' name='p416' value='23.00' style='align: center;width: 45px; padding: 2px; border: 1px solid black'>

                        <input type='hidden' name='i416' value='416'>
                         = <b>$</b>23     <font size='+1'><a class='deleteCardFromTradeButton'>X</a></font> 

                        <object data="http://www.gatheryourmagic.com/wp-content/plugins/mtg-card-links/getter.php?n=Sphinx's Revelation" height=400><embed src='http://www.gatheryourmagic.com/wp-content/plugins/mtg-card-links/getter.php?n=Sphinx's Revelation'> </embed> Error: Embedded data could not be displayed. </object>
                        <textarea rows='2' cols='10' name='s416' style='align: center;width: 300px; padding: 2px; border: 1px solid black'></textarea>
                        <img src="http://ark42.com/mtg/pricehistory.php?s=Return to Ravnica&amp;c=Sphinx's Revelation&amp;f=0&amp;d=0&amp;p=1" width='261' height='125' alt=''><br>
                        Powered by <a href='http://www.ark42.com/mtg' target=_blank>http://www.ark42.com/mtg</a>
                        </td><td></td></tr><tr><td><input type=submit value='Update &#x2713;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Total = $160.7</b></td></table></form></td></tr></table>
4

1 に答える 1

0

各セルの内容を新しい行にコピーしようとするとinnerHTML、画像がリロードされないと思います。

于 2013-09-05T08:31:58.327 に答える