2011-11-24 28 views
1

我正在开发一个php页面,管理对一些酒吧的访问.... 现在我卡住了一个地狱的问题。ajax调用脚本后jquery不再工作

让我解释一下....

我有一个按钮,调用ajaxrequest和重装称为#entry 出现的问题,当我尝试访问#entry的疗法财产Ajax请求之后的特定股利。

HTML结构

<div id="all"> 
    <div id="prenotazioni" class="mobile-left"> 
     <? CController::renderpartial('_lista'); ?> 
    </div> 
    <div id="entry" class="mobile-right" style="width:280px;position:absolute;bottom:0px;right:0px;"> 
     <? CController::renderpartial('_pren'); ?> 
    </div> 
</div> 

和有问题的jQuery代码的遵循

 $(window).scroll(function() { 
       $("#all").parent("div").find("#entry").css("bottom",""); 
       $("#all").parent("div").find("#entry").css("top", $(window).height() - $("#entry").outerHeight() + $(window).scrollTop() + "px");   
     }); 

,直到我叫AJAX everithing没有什么后正常工作......有人会帮我?????

感谢

EDITED

jQuery('body').undelegate('#yt0','click').delegate('#yt0','click',function(){jQu‌​ery.ajax({'type':'GET','data':{'id_lista':-1},'url':'/mobile/showlista','cache':false,'success':function(html){jQuery("#all"‌​).html(html)}});return false;}); 

_PREN

<div id="tipo"></div> 
<input name="report[id_pren]" id="report_id_pren" type="hidden" value=""/> 
<div id="ingresso"> 
<table> 
    <tr> 
     <td> 

     </td> 
     <td> 

     </td> 

    </tr> 
    <tr> 
     <td style="margin-right: 10px;"> 
      <div class="male" > 
       <span id="male_nr" class="nr">0</span> 
      </div> 
     </td> 
     <td> 
      <div class="female"> 
       <span id="female_nr" class="nr">0</span> 
      </div> 
      <div class="clear"></div> 
     </td> 

    </tr> 
    <tr> 
     <td style="line-height: 53px;">INGRESSI 
      <div id="totale_div" style="float:right;"> 
       <span id="totale">0</span> 
      </div> 

      </td> 
     </td> 
     <td rowspan="2" style="text-align:right;"><input type="image" src="../images/mobile/invio.gif" /></td> 
    </tr> 
    <tr> 
     <td style="line-height: 53px;"> 
      OMAGGI 
      <div id="omaggi_div" style="float:right;"> 
       <span id="omaggi"> 0</span> 
      </div> 

     </td> 

    </tr> 
    <tr> 
     <td style="width:50px;"> 
      <input type="button" id="omgplus" class="omgplus" /> 
      <input type="button"id="omgminus" class="omgminus" /> 
     </td> 
    </tr> 

</table> 
</div> 
+0

请过帐您的AJAX调用。 –

+0

ajax调用html结构发生改变后有可能吗? – Samich

+0

告诉我们如何加载ajax,以及如何在DOM中插入结果 –

回答

0

您与来自Ajax调用返回的结果替换#all元素的内容。因此#prenotazioni#entry都会从DOM中移除。

也许你需要在#prenotazioni元素中放入ajax结果。如果是使用

jQuery("#prenotazioni"‌​).html(html)} 

通则说明

$("#all").parent("div").find("#entry").css(..) 

应该

$("#all").find("#entry").css(..) 

因为#all#entry一个容器,这样你就不需要再上去DOM层次..

+0

可悲的是我不能这样做....我需要更新这两个分区...之后,我需要访问在CSS属性。 – Aliceiw

+0

@ Sakuya84,但返回的代码(*,如果_PREN是*)不包含'#entry'元素.. –

+0

解决谢谢 – Aliceiw