0
我在那裏被阿賈克斯產生與類confirm_booking
錨標籤的情況。所以我用delegate
。現在也通過Ajax的生成代表不工作的Ajax加載的內容
包含該錨在div。
加載通過Ajax的DIV此函數失敗之後。
$('.restro_book_div').delegate('a.confirm_booking', 'click', function (event) {
event.preventDefault();
$('ul.time a').removeClass('clicked_confirmed');
$(this).addClass('clicked_confirmed');
var $current = $(this);
var $reserve_restaurant_id = $current.attr('reserve_restaurant_id');
var $reserve_time = $current.attr('reserve_time');
var $table_type_id = $current.attr('table_type_id');
var $reserve_date = $current.attr('reserve_date');
var $reserve_slot = $current.attr('reserve_slot');
var $reserve_discount = $current.attr('reserve_discount');
var $reserve_loyalty_points = $current.attr('reserve_loyalty_points');
var $reserve_table_type = $current.attr('reserve_table_type');
// alert(document.getElementById('standard-dropdown').value);
// console.log($current);
// console.log($reserve_loyalty_points);
var $jquery_time = $current.attr('jquery_time');
var $restro = $current.attr('restro');
$target = $current;
var popID = $target.attr('rel'); //Get Popup Name
var popURL = $target.attr('href'); //Get Popup href to define size
<?
php
if (is_user_logged_in()) { ?>
$('#' + popID + ' .popup_heading').html('<span>THIS BOOKING IS VALID FOR</span> ' + $reserve_table_type + ' <span>PEOPLE AT</span> ' + $restro + '<br/> <span>ON</span> ' + $reserve_date + ' <span>AT</span> ' + $jquery_time); <? php
} ?>
//Pull Query & Variables from href URL
var query = popURL.split('?');
var dim = query[1].split('&');
var popWidth = dim[0].split('=')[1]; //Gets the first query string value
//Fade in the Popup and add close button
$('#' + popID).fadeIn().css({
'width': Number(popWidth)
}).prepend('<a style = "display:inline;" href="#" class="close"><img src="<?php echo DIVATEMPLATEPATH."/".IMAGEPATH ?>/close.png" class="btn_close" title="Close Window" alt="Close" /></a>');
//Define margin for center alignment (vertical horizontal) - we add 80px to the height/width to accomodate for the padding and border width defined in the css
var popMargTop = ($('#' + popID).height() + 80)/2;
var popMargLeft = ($('#' + popID).width() + 80)/2;
//Apply Margin to Popup
$('#' + popID).css({
'margin-top': -popMargTop,
'margin-left': -popMargLeft
});
//Fade in Background
$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
$('#fade').css({
'filter': 'alpha(opacity=80)'
}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies
return false;
});
沒有運氣,我已經嘗試過了。 :( –
如果這一點兒也不工作,你要麼必須與類confirm_booking無錨元素,或者您使用的是舊版本的jQuery? – adeneo
的這件事是工作時錨標記的父DIV是靜態的,但不是噹噹通過AJAX產生.restro_book_div然後它不工作這動態地 –