javascript - Array.filter breaking safari print -
i have print function works in except safari. when print button clicked, error thrown:
typeerror: 'undefined' not function (evaluating 'array.filter( document.getelementsbyclassname('printarea_1'), function(elem){ $(".printing_list").printelement( elem ); })')
the thing breaking safari code array.filter, witch works in except safari:
array.filter( document.getelementsbyclassname('printarea_1'), function(elem){ $(".printing_list").printelement( elem ); });
i have tried adding chunk of code supposed make work safari, doesn't. can me work, or me write can replace works in browsers?
here full print function
function print_list(item_names,number_of_items) { var thetext="<ol>"; for(var i=1; i<=number_of_items;i++){ if($("#" + item_names + "_" + i).val()!=''){ thetext+="<li>" thetext+=$("#" + item_names + "_" + i).val(); thetext+="</li>"; } } thetext +="</ol>"; $("#print_content_area").html(thetext); array.prototype.filter.call( document.getelementsbyclassname('printarea_1'), function(elem){ $(".printing_list").printelement( elem ); }); }
i’m not sure how possibly work in other browsers. array.filter
doesn’t exist; polyfill creates array.prototype.filter
, correct function. can use .call
adapt array-like object:
array.prototype.filter.call( document.getelementsbyclassname('printarea_1'), function(elem){ $(".printing_list").printelement( elem ); });
but filter
isn’t right function that; foreach
is.
and… have jquery?
$('.printarea_1').each(function() { $('.printing_list').printelement(this); });
it seems should cache $('.printing_list')
, too.
so want this?
$('.printing_list').append($('.printarea_1')).printelement();
Comments
Post a Comment