javascript - jQuery not working well on firefox and not working at all in Safari -
i using jquery.unique() rid of double values inside javascript array. in chrome works nice , length of array goes 60 29, in firefox strange goes 60 43 , in safari doesn't work @ all, hint? here imports use:
<title>aps</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <link href="../css/jquery-ui-1.10.4.css" rel="stylesheet"> <link rel="stylesheet" href="../css/reset.css"> <link href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/shift.css" rel="stylesheet"> <link rel="stylesheet" href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/bootstrap.css"> <script src="../js/jquery-1.10.2.js"></script> <script src="../js/jquery-ui-1.10.4.js"></script> <script src = "../js/search.js"></script> <link rel="stylesheet" href="../css/styles.css"> <script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.2.18.min.js"></script> </head>
and js:
$(function() { parse.initialize("t1s9kr0seibdujxpyozayccrgmvjmwooaqclbddo", "iigfcsejntivfhtieumgelgx9vru9mbdmora8ssz"); var query = new parse.query("pruebas"); query.find({ success: function(objects) { var centros=["villaviciosa", "el valle", "palomera", "encinar", "san mateo"]; var tipos = ["esporadico", "semanal", "esperando"]; var nombres=[]; var pruebas = ["nacho", "nacho ", "nacho", "nacho"]; console.log(pruebas.length+pruebas); console.log(jquery.unique(pruebas).length+jquery.unique(pruebas)); var emails=[]; var dias = [];//"lunes", "martes", "miercoles", "jueves", "viernes", "sabado", "domingo"]; var dnis=[]; var =0; objects.foreach(function(obj) { nombres[i] = obj.attributes.nombre; emails[i] = obj.attributes.mail; dnis[i] = obj.attributes.dni; dias[i] = obj.attributes.dia; i++; }); console.log("longitud de dias antes: "+dias.length); console.log("longitud de dias despues: "+jquery.unique(dias).length); $('#nombres').focus(); $( "#nombres" ).autocomplete({ select: function( event, ui ) {console.log(ui.item.value);$('#emails').val('');$('#dnis').val(''); $('#dias').val('');$('#centros').val('');$('#tipos').val('');}, source: nombres, autofocus: true }); $( "#dias" ).autocomplete({ select: function( event, ui ) { console.log(ui.item.value); console.log( objects.filter(function( obj ) { return obj.attributes.dia == ui.item.value; })); $('#emails').val('');$('#dnis').val(''); $('#nombres').val('');}, source: jquery.unique( dias ), autofocus: true }); $( "#emails" ).autocomplete({ select: function( event, ui ) {console.log(ui.item.value);$('#centros').val('');$('#nombres').val('');$('#dnis').val(''); $('#dias').val('');$('#tipos').val('');}, source: emails, autofocus: true }); $( "#dnis" ).autocomplete({ select: function( event, ui ) {console.log(ui.item.value);$('#centros').val('');$('#emails').val('');$('#nombres').val(''); $('#dias').val('');$('#tipos').val('');}, source: dnis, autofocus: true }); $( "#centros" ).autocomplete({ select: function( event, ui ) {console.log(ui.item.value);$('#emails').val('');$('#nombres').val('');}, source: centros, autofocus: true }); $( "#tipos" ).autocomplete({ select: function( event, ui ) {console.log(ui.item.value);$('#emails').val('');$('#nombres').val('');}, source: tipos, autofocus: true }); }, error: function(error) { console.log("an error occured :("); } }); $('#borrarbusq').click(function(){ $('#nombres').val(''); $('#emails').val(''); $('#dnis').val(''); $('#dias').val(''); $('#tipos').val(''); $('#centros').val(''); }); });
thanks!!
jquery.unique works on dom elements only:
description: sorts array of dom elements, in place, duplicates removed. note works on arrays of dom elements, not strings or numbers.
you need implement own routine or use lodash or underscore
Comments
Post a Comment