Jump to content

elcaiaimar

Members
  • Posts

    39
  • Joined

  • Last visited

elcaiaimar's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hi, I having problems when I execute (from a JS file) an onclick function by the class that is into an append of another JS file. My code is this: JS File1: var user_tmpl = $('<div />') .addClass('user') .append('<strong/>').find('strong').addClass('titulo').html(item.titulo) .append('<a href="#buscamedioModal" role="button" class="btn btn-danger deletebuscamedio" data-toggle="modal" id=' + item.gid + ' data-name=' + item.titulo + '>Eliminar</a>') .parent(); JS File2 (call): // Configuraciones Generales var boton_eliminar_buscamedio = ".deletebuscamedio"; // Clase // Fin de configuraciones $(document).on('ready',function(){ $(boton_eliminar_buscamedio).on('click',function(e){ e.preventDefault(); var Pid_medio = $(this).attr('id'); alert(Pid_medio); var name_buscamedio = $(this).data('name'); But it seems that it can't run the function because doesn't find the class "deletebuscamedio". Does anyone how to do this? Thank you in advance!
  2. Hello, what it happens is that when I try to save the attributes on scopes, they are undefined. There aren't errors in my browser console. After your answer, How could I get the file information and save it in scopes. My main problem is with javascript. Thank you very much!
  3. Hello everybody, I'm new in angular so sorry if my question is ridiculous. I have a drag and drop file area and when I put a file I put his details (attributes: name, size, type) on inputs disabled because I don't want that users can change them. All of that is a form, so I want to save this with angular in scopes. Here my code: <div ngf-drop ngf-select ng-model="files" class="drop-box" ngf-drag-over-class="'dragover'" ngf-multiple="true" ngf-allow-dir="true" accept="{{acceptSelect}}" ngf-pattern="pattern" required>Arrastre y suelte su archivo aquí</div> <div ngf-no-file-drop>File Drag/Drop is not supported for this browser</div> <br> <div class="preview"> <div>Detalles del video: <div style="clear:both" class="videodetails" ng-repeat="file in files"> <div class="form-group"> <label class="col-md-4 control-label" for="fileName">{{ "Nombre" }}</label> <div class="col-md-5"> <input id="fileName" type="text" ng-model="file.name" disabled> </div> </div> <div class="form-group"> <label class="col-md-4 control-label" for="fileSize">{{ "Tamaño" }}</label> <div class="col-md-5"> <input id="fileSize" type="text" ng-model="file.size" disabled> </div> </div> <div class="form-group"> <label class="col-md-4 control-label" for="fileType">{{ "Tipo" }}</label> <div class="col-md-5"> <input id="fileType" type="text" ng-model="file.type" disabled> </div> </div> JavaScript: $scope.file = function (data) { $scope.file.fileName = data.name; $scope.file.fileSize = data.size; $scope.file.fileType = data.type; } I don't know what I'm doing wrong. Any help? Does anybody know to fix it? Thank you very much!
  4. Hello! I have a map in my website and when I click on it, if there is a feature, it shows its information. This information is written by an innerHTML and currently it looks like that: if (feature) { var objeto = feature.getProperties(), propiedades; var propiedades; content.innerHTML = ""; for (propiedades in objeto){ content.innerHTML += propiedades + ':' + objeto[propiedades] + "<br />"; } return container.style.display = 'block'; } else { return container.style.display = 'none'; } So the info is shown ok but a little untidy. So I would like to show this info with a table. propiedades contains the name of the data and objeto[propiedades] their values. Could anybody tell me how to do it or give me an example please? Thank you in advance!
  5. Hello, I've a problem when I try to send variables (django variables) from html to javascript. My variables contain coordinates, I mean, they are decimals, and when I receive them in the javascript and I show them in console, I've got only the no decimal part of the coordinates. This is my code: Template: <td><button onclick="window.to('{{p.coorx}}','{{p.coory}}')" data-coorx="{{p.coorx}}" data-coory="{{p.coory}}">Ver Pozo</button></td> Javascript: window.to = function(coorx,coory) { var coorx = parseFloat(coorx); var coory = parseFloat(coory); console.log(coorx); console.log(coory);} I'm sure that my error is in the way in what I establish the parameters to send in HTML. I've tried several choices as: <td><button onclick="window.to(" + {{p.coorx}} + "," + {{p.coory}} + ")" data-coorx="{{p.coorx}}" data-coory="{{p.coory}}">Ver Pozo</button></td> But then it gives me an error: Uncaught SyntaxError: Unexpected token } Would anybody know how to solve this problem? Greetings and thank you very much in advance!
  6. Now, I click a button to remove db registers so I don't want to click another button to execute the map script. I think that the best way would be to click in the delete button, then shows an alert saying removed and automatically execute the script. For that, I've thought in execute it from the code above, if it was possible.
  7. Ok, thanks for your clarification. Just a question, How could I run the script from my code? I've seen that you can do it with events but I dont want to use any button to do it. Thank you again!
  8. Hello, I'm trying to reload only a script instead of entire page. And I want to apply it in an ajax script. How could I do that? My web contains a map(script of openlayers) and I put data into the map. So when I remove this data by a button I would like reload only the map. Here is my code. It only shows an alert if the object has been removed or not: // Autor: @jqcaper// Configuraciones Generalesvar nombre_tabla_pozos = "#tabla_pozos"; // idvar nombre_boton_eliminar_pozo = ".deletepozo"; // Clasevar nombre_formulario_modal_pozo = "#frmEliminarpozo"; //idvar nombre_ventana_modal_pozo = "#pozoModal"; // id// Fin de configuraciones$(document).on('ready',function(){ $(nombre_boton_eliminar_pozo).on('click',function(e){ e.preventDefault(); var Pid_pozo = $(this).attr('id'); var name_pozo = $(this).data('name'); $('#modal_idPozo').val(Pid_pozo); $('#pozo_name').text(name_pozo); }); var options_pozo = { success:function(response) { if(response.status=="True"){ alert("¡Object removed!"); var idPozo = response.pozo_id; var elementospozo= $(nombre_tabla_pozos+' >tbody >tr').length; if(elementospozo==1){ location.reload(); }else{ $('#tr'+idPozo).remove(); $(nombre_ventana_modal_pozo).modal('hide'); } }else{ alert("¡There was an error when remove!"); $(nombre_ventana_modal_pozo).modal('hide'); **RELOAD SCRIPT }; } }; $(nombre_formulario_modal_pozo).ajaxForm(options_pozo);}); Thank you very much!
  9. That is! It works! Sorry but I didn't find the solution. Thank you very much!
  10. Sorry, but I'm trying everything and don't get anything. Can you tell me how you would do it with my code? I'm still a newbie in JS Thank you for your fast answers!
  11. I've tried to put that: var myVar = 1;var tramosSource = new ol.source.ServerVector({ format: new ol.format.GeoJSON(), loader: function(extent, resolution, projection) { var url = 'http://localhost:808...wfs?service=WFS' + '&version=1.1.0&request=GetFeature&typename=cia:tramos&PROPERTYNAME=gid_cuenca_id&CQL_FILTER=gid_cuenca_id="myVar"&' + 'outputFormat=text/javascript&format_options=callback:tramosloadFeatures' + '&srsname=EPSG:3857'; $.ajax({ url: url, dataType: 'jsonp' }); }, projection: 'EPSG:3857' }); But I have the same problem: Uncaught SyntaxError: Unexpected token < <ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/ows http://localhost:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd"> <ows:Exception exceptionCode="InvalidParameterValue"> <ows:ExceptionText>Illegal property name: myVar</ows:ExceptionText> </ows:Exception></ows:ExceptionReport>
  12. Hello! I'm working in a viewer with openlayers and with geoserver and I want to filter layers by a variable. I'm not going to ask anything about geoserver nor openlayers. My problem is about put variables in a url. To obtain geoserver layers from openlayers you have to call them by a url and to filter them you have to use CQL_FILTER. (Filter to shows only what the user wants). My viewer works fine if I put a simple value to filter: (gid_cuenca_id is a db column) var imbornalesSource = new ol.source.ServerVector({ format: new ol.format.GeoJSON(), loader: function(extent, resolution, projection) { var url = 'http://localhost:8080/geoserver/cia/wfs?service=WFS' + '&version=1.1.0&request=GetFeature&typename=cia:imbornales&PROPERTYNAME=gid_cuenca_id&CQL_FILTER=gid_cuenca_id=1&' + 'outputFormat=text/javascript&format_options=callback:imbornalesloadFeatures' + '&srsname=EPSG:3857'; $.ajax({ url: url, dataType: 'jsonp' }); }, projection: 'EPSG:3857' }); However, if I try to put a variable in the url, I receive an error: Uncaught SyntaxError: Unexpected token <I wanted to know if there is any way to put the variable's value as if it was a simple value. var myVar = 1;var tramosSource = new ol.source.ServerVector({ format: new ol.format.GeoJSON(), loader: function(extent, resolution, projection) { var url = 'http://localhost:8080/geoserver/cia/wfs?service=WFS' + '&version=1.1.0&request=GetFeature&typename=cia:tramos&PROPERTYNAME=gid_cuenca_id&CQL_FILTER=gid_cuenca_id=myVar&' + 'outputFormat=text/javascript&format_options=callback:tramosloadFeatures' + '&srsname=EPSG:3857'; $.ajax({ url: url, dataType: 'jsonp' }); }, projection: 'EPSG:3857' }); Thank you very much!!
  13. Hello, first of all, thank you for your answer. I've been looking for examples and I've found a code. I've tried to change it to adapt it to my URL but I always receive the same: null Could you help me with my URL? http://localhost:8000/edicioncuenca/obra=2/cuenca=1/ function getParameter(paramName) { var searchString = window.location.search.substring(1), i, val, params = searchString.split("/"); for (i=0;i<params.length;i++) { val = params[i].split("="); if (val[0] == paramName) { return val[1]; } }return null;var cuenca=getParameter("cuenca");alert(cuenca); Thank you again!
  14. Hello, I'm working in a website development with django and I need to send a parameter to a script. On my web, I send parameters through the URL on this way: I put the href in which {{obra.id}} is the object received from views.py href="/edicionobra/obra{{obra.id}}/"> At the url I take that object as parameter to go to one page or another, according its value, url(r'^edicionobra/obra(?P<id_obra>.*)/$','demo.apps.obras.views.EdicionObra', name='edicionobra'), However, I would like to take that parameter to use it in a script, but I don't know how to do it. Would anybody know how to solve this? Thank you very much!
  15. I fix it! I put css('display', 'table-row'); and it looks well!
×
×
  • Create New...