Prev | Current Page 133 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

responseText + ")") ;
if(json.result && json.id == this.id) { #1
var id = json.id;
// update the information text to include the new counts
document.getElementById('yes-'+ id).innerHTML = json.helpful_yes;
document.getElementById('total-'+id).innerHTML = json.helpful_total;
// say thank you and stop the spinner
this.message("success", 'Thankyou for your feedback.');
this.stopSpinner();
// remove yes/no buttons as they aren't needed after feedback
document.getElementById('yesno-'+ id).innerHTML = "";
} else {
this.failure(o); #2
}
}
}
(annotation) <#1: Sanity checks: Check that we got back the same review Id as we sent.>
(annotation)<#2: If the sanity checks fail, then treat this as any other failure.>
As we noted earlier, the success function has to do three different things: update the review count text,
display a thank you message and stop the spinner. We also remove the Yes and No buttons as they are no
longer needed. To update the count, we deliberately placed a with an id of helpful-{review_id} around
the two numbers that we needed to update. We then set the innerHTML property of the two spans to update the
new number of ???yes??? and ???total??? counts. To update the message and stop the spinner, we use the helper
functions that we previously created, which ensures that this function is easier to maintain.


Pages:
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
lampy ogrodowe określić zakłady bukmacherskie Wczasy nad morzem Gabi meble Warszawa