Thread Perlscript soll buttons (nicht Typ submit) clicken (28 answers)
Opened by user23432 at 2013-09-14 08:53

jan
 2013-09-16 00:40
#170267 #170267
User since
2003-08-04
2536 Artikel
ModeratorIn
[Homepage] [default_avatar]
Wie vermutet: jQuery-Eventlistener in der functions.js:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
        $j('.real_time_availability_listing').click(function(e){
var the_element = $j(this);
//remove error message if it's there
the_element.siblings('p.error').remove();

// replace with spinners
var availabilityRow = the_element.closest('tr').find('p.availability');
availabilityRow.html('<img src="'+ BASE_URL +'skin/frontend/csg/default/images/ajax-loader.gif' + '" />').attr('data-sku');
var skus = '';

availabilityRow.each(function() {
skus += 'skus[]=' + $j(this).attr('data-sku') + '&';
});

$j.ajax({
type: 'GET',
url: BASE_URL + 'catalog/product/availability',
data: skus,
dataType: 'json',
success: function(data){
if (data.error) {
the_element.after('<p class="error">' + data.message + '</p');
availabilityRow.html('unknown').addClass('error');
}
$j.each(data.availability_list, function(i, item) {
$j('p.availability[data-sku="'+item.sku+'"]').html(item.message);
if ($j(".future_availability")[0] && item.cssclass=='instock')
{
// Do something here if class exists
$j("p.future_availability[data-sku='" + item.sku + "']").html(item.fmessage);
}
else if (item.quantity == 0 && item.message == '' )
{
$j("p.availability[data-sku='" + item.sku + "']").html(item.fmessage);
}

//remove instock and outofstock classes just in case they've already been populated
$j('p.availability[data-sku="'+item.sku+'"]').removeClass("instock");
$j('p.availability[data-sku="'+item.sku+'"]').removeClass("outofstock");
if (item.cssclass=='instock') {
$j('p.availability[data-sku="'+item.sku+'"]').addClass("instock");
}
else if (item.cssclass=='outofstock'){
$j('p.availability[data-sku="'+item.sku+'"]').addClass("outofstock");
}
});
}
});
});


Damit siehst Du ja, welche Ajax-Requests da ausgelöst werden. Du musst also nur die SKUs finden und sie dann an die url BASE_URL + 'catalog/product/availability' übergeben und schon läuft das.

View full thread Perlscript soll buttons (nicht Typ submit) clicken