开发者

.empty() is not working using js in PHP in my ajax poll

I am trying to update my poll when people press on vote. everything is fine, except that I don't redirect to the result. to simplify the matter I am just trying to empty the div holding my poll after u开发者_如何学Cser press VOTE. Here is the code

$js = "
window.addEvent('domready', function(){
    $('poll_vote_".$poll->id."').addEvent('submit', function(e) {
      new Event(e).stop();

      $('submit_vote_".$poll->id."').disabled = 1;
          $('poll_loading_".$poll->id."').setStyle('display','');
      // Update the page
      this.send({ 
          onComplete: function(response, responseXML) {
                    $('polldiv_".$poll->id."').empty(); 
          }});

        }); 
 }); 
$document->addScriptDeclaration( $js );

Now everything is fine (and I get the votes correctly), but $('polldiv_".$poll->id."').empty(); this is not working at all.


Assuming that polldiv_<poll-id> and the other selectors correspond to tag ID's, you need to prefix the selectors with a # character.


Edit: So basically the final rendered HTML should be something like: $('#polldiv_POLL-ID')


If you're selecting by ID, you're missing the # in every reference. $('poll_vote_".$poll->id."') should be $('#poll_vote_".$poll->id."').

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜