jQuery(document).ajaxComplete(function(e, xhr, settings){ var d = document.location.pathname + document.location.search + document.location.hash; _gaq.push(['_trackPageview', d]); });Source: http://stackoverflow.com/questions/7737549/google-analytics-and-loading-a-page-using-ajax-get-request
Showing posts with label jquery. Show all posts
Showing posts with label jquery. Show all posts
Friday, November 16, 2012
Add AJAX Request to Google Analytics
If you use jQuery you can bind to the global AjaxComplete event to fire a Pageview everytime an Ajax call completes:
Thursday, March 1, 2012
Useful jQuery Tips
Check if a checkbox is checked:
if($('#checkbox').is(':checked')) ...
Check if a select option is selected:
if($('#select option:selected').length()) ...
Get the selected radio value:
$('.radio:checked').val()
Get all inputs with a classname begins with rescheck:
$("input[class^=rescheck-]").each(
function() {
alert($(this).attr('class'));
}
);
Jump to ( Scroll To ) an element:
$('html, body').animate({ scrollTop: $("#some_element").offset().top }, 500);
Checking to see if there is an attribute on an element:
var attr = $(this).attr('name');
if (typeof attr !== 'undefined' && attr !== false) {}
Clear selection on select:
$("#my_select option:selected").removeAttr("selected");
Ajax request and putting the result array into a select:
$.post("/url", function(data) {
var selected = '';
$.each(data, function(key, data) {
$('#foobar').append("");
});
});
if($('#checkbox').is(':checked')) ...
Check if a select option is selected:
if($('#select option:selected').length()) ...
Get the selected radio value:
$('.radio:checked').val()
Get all inputs with a classname begins with rescheck:
$("input[class^=rescheck-]").each(
function() {
alert($(this).attr('class'));
}
);
Jump to ( Scroll To ) an element:
$('html, body').animate({ scrollTop: $("#some_element").offset().top }, 500);
Checking to see if there is an attribute on an element:
var attr = $(this).attr('name');
if (typeof attr !== 'undefined' && attr !== false) {}
Clear selection on select:
$("#my_select option:selected").removeAttr("selected");
Ajax request and putting the result array into a select:
$.post("/url", function(data) {
var selected = '';
$.each(data, function(key, data) {
$('#foobar').append("");
});
});
Labels:
jquery
Tuesday, January 10, 2012
Allow Only Numbers (0-9) in Input Fields with jQuery
$(".numbersOnly").keydown(function(e){ var key = e.charCode || e.keyCode || 0; // allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY return ( key == 8 || key == 9 || key == 46 || (key >= 37 && key <= 40) || (key >= 48 && key <= 57) || (key >= 96 && key <= 105)); });
Labels:
input,
integer,
javascript,
jquery,
number,
validation
Friday, November 19, 2010
Avoid Scrollbars when using JQuery Accordion
Use the fillSpace and clearStyle options and set them to TRUE.
$("#accordion").accordion({ fillSpace: true, clearStyle: true });
Subscribe to:
Posts (Atom)