Posts by Pedro Camara Junior • 6,637 points
151 posts
-
0
votes3
answers1180
viewsA: Transfer the value of a variable to Ctrl+C
Some time ago I needed and used that code. Below, the code and example of use: (function (angular) { 'use strict'; /// Diretiva para simular o Copy to Clipboard /// Será copiado o texto passado na…
-
1
votes2
answers4863
viewsA: Reading XML in C#
You can read and write the data using the class Xmlserializer, for this, you only need to have a class that represents the content of your XML, I will use as a basis the part of XML that you posted.…
-
6
votes2
answers2116
viewsA: Format Angularjs date
Response adapted from: how-to-format-a-date-in-format-dd-mm-yyyy Use the Angularjs filters To format dates in Angular, there is the Angular Filter which is very useful and easy to use, whether in…
-
2
votes5
answers7507
viewsA: Change function of onclick
Particularly I think it is better to have two buttons, one for each action, and the moment you click on one, hide the other, and so on, see in the example: .on('click', function () { ... }: assigns…
-
0
votes3
answers62
viewsA: Click for more than one item
There are several ways to do this, such as creating a display variable for each content, and checking in the click function which one is being called, see: var app = angular.module('myApp', []);…
angularjsanswered Pedro Camara Junior 6,637 -
7
votes2
answers233
viewsA: problems with string and split C#
Can make a split using Regex, this way you can consider a pattern to separate the string. Let’s consider that our pattern for separating is everything that is not a number except points (which may…
-
2
votes4
answers1037
viewsA: Capture form data and transform to UPPERCASE
You can convert the value to uppercase and reassign to input the uppercase value at some input event. See the example below where I change the value in the event blur (when it loses focus), so when…
-
2
votes1
answer1152
viewsQ: Sending complex objects via Httpget
I have a search method in my Webapi, as it is a search, I used [HttpGet], as a parameter of this method, I pass an object with the filter options I want, for example: public class ParametrosBusca {…
-
6
votes2
answers116
viewsA: How to use a tag property, using Jquery
Use the data attribute of HTML To access a value from a date type attribute using jQuery use $('elemento').data('nome-atributo') $("#selectTeste").on("change", function() { var exigeIdade =…
-
8
votes2
answers7180
viewsA: Get the value of radio input with javascript
You can use the javascript method queryselector and match the javascript selectors: document.querySelector('input[name="q1"]:checked').value;…
javascriptanswered Pedro Camara Junior 6,637 -
4
votes3
answers1044
viewsA: How to edit and load class only for a single element
The solution to your problem is quite simple, you just need to have a property boolean within each user, we will use this property to show or hide the specific user editing html, see my example: I…
angularjsanswered Pedro Camara Junior 6,637 -
1
votes4
answers4653
viewsA: Icone in input with bootstrap
Use the classes input-group and input-group-btn as in the example: <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> <div…
-
5
votes4
answers239
viewsQ: Ignore class name in XML serialization
I need to serialize a class for XML, for example: public class Pessoa { public string nome { get; set; } public int idade { get; set; } public Endereco endereco { get; set; } } public class Endereco…
-
2
votes1
answer1126
viewsA: Place div next to div
Use the resources of bootstrap for this, in your case, use the concepts of grid system What is the Grid System? Grid System is used to create page layouts using a series of rows and columns, your…
-
4
votes2
answers2323
viewsA: Disable button after jQuery click
You set two behaviors for the button click event $('body').on('click', '[data-link]', function() { ... }); $('button').click(function () { ... }); Javascript will adopt one or the other, in your…
-
0
votes3
answers88
viewsA: What is the correct way to call function within another nested function?
You just need to take the declarations of the functions from within the scope of the function principal, doing this, they will be accessible globally and not only in the scope of the function…
javascriptanswered Pedro Camara Junior 6,637 -
0
votes2
answers35
viewsA: Dropdown Hover work just above 1200px
You can check inside the Hover function, and if it is true it does nothing, see the code: var $meuLink = $('#meuLink'); var $divMostrarOcultar = $('#divMostrarOcultar'); $meuLink .on('mouseover',…
-
1
votes3
answers186
viewsA: Doubt validate . click() outside of Function() jQuery
As the function of .pop-no is only to hide the class element .pop, you just need to check if .pop is being shown or not when clicking on .pop-yes. How to check? Use the function is(':visible')…
-
4
votes3
answers1079
viewsA: Problem checking all checkboxes
Save the current value in a variable: var isChecked = $('#ckeckAll').is(':checked'); And "reverse" the value of checked $('#ckeckAll').prop('checked', !isChecked); If checked, will change to not…
-
3
votes3
answers84
viewsA: Partial selection of a class with jQuery
The @Lucas Costa answer already solves your problem in a great way, I’ll just post another possible way using the String.replace(). var $divChart = $("div[class^='chart-']"); var divClasses =…
-
0
votes1
answer113
viewsA: Error returning date
I think you don’t need all this just to format, you can use the function toLocaleDateString and format using the second parameter. I’ve formatted as you wish, but take a look at the documentation…
-
3
votes2
answers1519
viewsA: Subtract date with javascript
Using javascript only Use the method Date.setHours(0, 0, 0, 0) - passing zero to the constructor to reset the hours To compare dates, use the method Date.getTime() that will return an integer with…
-
2
votes4
answers353
viewsA: use F2 to click on jquery button
Use the keyup event and check if the keycode is 113 (F2), then just invoke the event of the element you want. $(document).on('keyup', function(e) { var keyCode = e.keyCode || e.which; if (keyCode…
-
1
votes5
answers3614
viewsA: Split array into smaller groups
Using a simple repeat loop, you can use the Array.Slice to separate the array and the Array.Push to create a new one with the extracted elements. function separarArray(arr, tamanho) { var novoArray…
-
1
votes4
answers7208
viewsA: How to group an object array in javascript (Angular)
One way is by using the Javascript Filter to find only the values you need and insert them into a new array using the push, See the example below: var arrayDeObjetos = [ {"dia":1 ,…
-
1
votes4
answers560
viewsA: How to return correctly the values of calculations with decimals in javascript?
The decimal separator is . and not ,. The way you did, the numbers are being considered integer and not decimal. var valor1 = parseFloat(126.79); var valor2 = parseFloat(237.00); var resultado =…
javascriptanswered Pedro Camara Junior 6,637 -
1
votes3
answers16786
viewsA: Change object value
One way to do it using javascript only, is to iterate the object, create a new property and delete the other, see in the example. var meuObjeto = [{ name: '2015', color: 'orange' }, { name: '2016',…
-
4
votes2
answers94
viewsA: How to implode to remove characters other than the +(plus) sign with Javascript?
Use a REGEX inside the split In that case \D means that it will perform the "split" whenever it finds a character that is not numerical. var valor = "10+20+30+40+50=150"; var valoresSeparados =…
javascriptanswered Pedro Camara Junior 6,637 -
1
votes2
answers2823
viewsA: Margins of the child element leaking to the parent element
Each browser has a standard style sheet, see in your inspector that the style is referencing to user agent stylesheet. For example, for the element <h1></h1>, in the case of Chrome will…
-
2
votes3
answers2067
viewsA: convert integer to decimal in jquery
You can use the method substring from Javascript to format var valor = "025"; var len = valor.length; var valorFormatado = valor.substring(0, len - 2) + "." + valor.substring(len - 2);…
-
4
votes3
answers1083
viewsA: How can I create a filter to fill with zero left at the angle?
Other option .filter('numberFixedLen' function () { return function (a, b) { return (1e4 + a + "").slice(-b) } }); Use: {{ valor | numberFixedLen:4 }}…
angularjsanswered Pedro Camara Junior 6,637 -
5
votes2
answers899
viewsA: How to remove waste on printing screens
Use the following bootstrap classes hidden-print: not to show in print - will be displayed in HTML visible-print: to display in print - will not be displayed in HTML Example: <link…
-
9
votes1
answer259
viewsA: Hide Divs with similar ID
See these two options CSS: div[id^='cn-'] { display:none; } or jQuery: $('div[id^="cn-"]').hide(); This will allow you to select all elements that contain cn- at the beginning of the ID. Taken from…
-
3
votes2
answers22
viewsA: Remove character from a generated value
Use the method substring(start, end). The method has two parameters to define what will be extracted: The first parameter you set the initial index you want - in the first char start example (0).…
javascriptanswered Pedro Camara Junior 6,637 -
2
votes1
answer1389
viewsQ: How to remove the hashtag (#) from the URL?
By default Angularjs formats the URL as follows: http://dominio.com.br/#/login How do I leave it this way? http://dominio.com.br/login
angularjsasked Pedro Camara Junior 6,637 -
3
votes1
answer1389
viewsA: How to remove the hashtag (#) from the URL?
It’s two very simple steps: Enable HTML5 on $locationProvider Configure the application’s base path Enable HTML5 angular.module('app', []) .config(function($routeProvider, $locationProvider) {…
angularjsanswered Pedro Camara Junior 6,637 -
2
votes2
answers1282
viewsA: How to run a Function after entering the Controller in Angularjs?
You can use the service $Location to get the path that is running. function EstadoNavegacao($location) { //... init(); function init() { var path = $location.path(); if (path ===…
-
2
votes1
answer127
viewsA: Problems with selector and jQuery
Use the function append to insert the html into the desired element and use the function Prev to select the item before your button. Note that the append will always add content at the end of…
jqueryanswered Pedro Camara Junior 6,637 -
6
votes1
answer205
viewsA: Click a button through Class
When you use the selector getElementsByClassName, the result will be an array of all elements containing this class, so to correct the error, you only need to define an index, for example l[0],…
javascriptanswered Pedro Camara Junior 6,637 -
0
votes3
answers82
viewsA: Javascript - Function problem that adds textbox
The innerHTML substutui all content, to add more content at the end use the append. Now two points in existing code: You are using javascript and jQuery in the same code, if you use jQuery, use as…
-
3
votes3
answers419
viewsA: How to turn a bool into int?
First you must use two signs && for the instruction and, and you should also do a check for each item, see: (Convert.ToInt32(_TextValMin.Text) != Convert.ToInt32(_TextValPalite.Text))…
-
0
votes2
answers1512
viewsA: Send data through Angular
Yes, it is wrong. When you declare your function in the controller, you say that you will receive a parameter, in this case data - that’s not wrong. $scope.Cadastrar = function(data) { ... } The…
-
0
votes2
answers764
viewsA: How to change the value of subsequent inputs?
I made an example in jQuery. I select all inputs that the data-produto be it 0101000 I add to all of them a Listen for the events change and keyup Save the value of the input that called the event I…
-
0
votes4
answers1021
viewsA: Balloon that brings information about the page
Can use jQuery and the Bootstrap JS Modal, which is a "plugin" of Bootstrap. $(document).ready(function() { $('.abrir-modal').on('click', AbrirModal); function AbrirModal() { var codigo =…
-
49
votes4
answers39339
viewsA: How to apply readonly in a select?
You can disable mouse, keyboard and touch events from select using only css, so the field will only have the appearance and behavior of disabled, but it will remain enabled. pointer-events: none -…
-
4
votes3
answers2170
viewsA: Pass values from a popup (child) to parent page
Use the property window.opener.Document to manipulate any element on the parent page. var $botaoFechar = document.getElementById('botaoFechar'); $botaoFechar.addEventListener('click', function () {…
-
6
votes1
answer435
viewsA: How to display only the first row of a table?
See the example using the selector :not(first-child) to manipulate only other lines. CSS: tr:not(:first-child) - Manipulate all rows in the table other than the first. Jquery tr:not(:first-child) -…
-
1
votes2
answers49
viewsA: Input file type as read-only
To disable an input-file use the property disabled Example in Javascript document.getElementById("myFile").disabled = true; Example with jQuery $('myFile').prop('disabled', true);…
jqueryanswered Pedro Camara Junior 6,637 -
5
votes2
answers4673
viewsA: How to simulate a keystroke with jQuery?
You can create the event and then trigger it. var teclaEsquerda = jQuery.Event("keypress"); teclaEsquerda.ctrlKey = false; teclaEsquerda.which = 37; //Código da tecla - seta esquerda…
-
2
votes2
answers720
viewsA: clear input with event onchange javascript
See the example using jQuery. I used keyup in the event, that is, the function will be invoked each time you enter something in the input. A tip, prefer to use id for the inputs instead of name, for…