Posts by bfavaretto • 64,705 points
902 posts
-
2
votes2
answers495
viewsA: How to call partial function after added via append
This type of ID has several characters that are not interpreted literally when used in a selector. For example, a selector like this: #Contatos[8902dbfd-e856-48c6-8f17-d0548b2dea62].Nome Find an…
-
2
votes1
answer63
viewsA: Result of strange serialize
It seems to me that you are confusing the function of PHP with that of jQuery. In PHP, the function serialize serves to serialize an object so that it can be stored, and not used in a query string…
phpanswered bfavaretto 64,705 -
6
votes1
answer90
viewsA: Add properties to the [Node] element
It is something that is usually recommended to avoid. Main reason: you may end up causing a name collision with a property that will be implemented in the DOM in the future. So even if today the…
-
4
votes1
answer248
viewsA: Good practice with XHR requests
As already pointed out by other users in the comments above, there are no "good practices" except in relation to the specific context of each application. So the answer is yes and nay. No, it is not…
-
5
votes3
answers1593
viewsA: Function as parameter in jQuery functions
The @Maniero response was on the fly, I highlight this excerpt: Usually data is passed to functions. This is a way to pass algorithms to functions. Note that this function you are creating is by…
-
2
votes1
answer817
viewsA: Doubt ajax request with angular js
You need to put all the code that depends on the result of the request inside the callback successful. At its current position, this code executes before the result is available, as the HTTP request…
-
8
votes3
answers4364
viewsA: What are decimal, hexadecimal, and octal notation numbers?
Numbers always represent a quantity, but there are several ways to represent numbers. The most common is the decimal system, which uses 10 digits (of 0 to 9). And what do we do in the decimal system…
-
4
votes1
answer99
viewsA: How to create a jQuery function to pull the menu up?
You did not give many details, but if only the animation of collecting the menu is missing, the slideUp() must solve: $("#esconder_menu").on("click", function(){ $('#header-main').slideUp(); });…
jqueryanswered bfavaretto 64,705 -
3
votes2
answers581
viewsA: Location of a point within the arc range
With a possible error of off-by-one in my random numbers, I think this is it: // Ângulos mínimo e máximo no círculo, em radianos var minDeg = Math.PI; var maxDeg = Math.PI * 5/4; // Ângulo sorteado…
-
3
votes3
answers517
viewsA: Create table without border
<table border="0"> Or in the CSS: table { border: 0; }
-
2
votes1
answer96
viewsA: How to pass a function as parameter in Action Script?
You can try using an array instead of the HashMap, and literal objects as value: var map = []; map.push({ alert: function() { trace("aaaaa") } }); map.push({ alert: function() { trace("bbbbb") } });…
actionscript-3answered bfavaretto 64,705 -
65
votes3
answers5311
viewsQ: When to use var in C#?
In C#, local variables in the scope of a method can be declared with implicit type using var, and type is solved at compile time: var i = 10; // implicitly typed int i = 10; // explicitly typed…
-
3
votes2
answers248
viewsA: Merge two tables into a third table
Considering that the correspondence between the tables is by the ID column, I didn’t understand why I would need two queries. I would do so: INSERT INTO imagens (id, imovel, codigo, imagem_g,…
-
0
votes3
answers1291
viewsA: How to recover the attribute of a dynamically created element?
You need to navigate to the element that contains the attribute, based on where it is relative to the clicked element. In this case, it is in a div .ui-block-a which is the sister of the link…
-
3
votes2
answers1739
viewsA: How to change the position on the map each time the user clicks a link?
This is the example of a basic map that is part of the Google Maps documentation: <!DOCTYPE html> <html> <head> <title>Simple Map</title> <meta name="viewport"…
-
2
votes2
answers102
viewsA: Search in related table
The error is there at the beginning of your code (the explanation is what Fernando said, there is more than one column with the same name involved in the query): $campo = 'CONCAT(descricao, " ",…
-
43
votes6
answers32107
viewsA: What is Vanilla JS?
It’s pure Javascript anyway. In English there is this expression "vanilla [Something]" to refer to the most common, simplest or purest variant of something - perhaps because "vanilla" is the most…
-
2
votes2
answers1020
viewsA: Assign various elements different values using the same function
You can create a dictionary format object, where the keys are the Divs Ids, and the values are the respective texts. Then just scroll through the dictionary to fill out the Divs: var textos = {…
jqueryanswered bfavaretto 64,705 -
5
votes1
answer266
viewsA: Create check multiple values of a variable
You can do this by placing the list of words in an array, and checking whether the value of the variable is contained in the list, with in_array: $statusPermitidos = array('Aberto', 'Em Andamento');…
phpanswered bfavaretto 64,705 -
4
votes1
answer1648
viewsA: How do 'request' and 'Response' events work on Node.js?
I think the way the documentation of the Node was written is confusing you. She says yes there is an event called request, and then shows the following: function (request, response) { } That part is…
-
3
votes1
answer4876
viewsA: How to merge result from two tables 1 - n
You can group the result by customer: SELECT cliente.id, cliente.nome, foto.conteudo FROM cliente LEFT JOIN foto /* use INNER JOIN se todo cliente tiver 1+ foto */ ON foto.cliente_id = cliente.id…
-
7
votes5
answers41788
viewsA: How to sort an array of objects with array.Sort()
The simplest solution is to pass a function to the method sort array, manually comparing the properties of objects containing the names. The sort uses this function to compare pairs of values, and…
javascriptanswered bfavaretto 64,705 -
4
votes2
answers1258
viewsA: Is it possible to open an IDLE file from the terminal?
You can open any file (including a new one, already giving it a name), simply by typing in the terminal: idle arquivo.py
pythonanswered bfavaretto 64,705 -
4
votes4
answers2296
viewsA: How to order three Ivs according to an attribute of hers?
How the question includes the tag javascript, I leave here a solution in pure JS, with the commented steps, for those who want to solve the same problem without jQuery: // Seleciona as divs que…
-
17
votes8
answers13920
viewsA: Is <br> or <br/> or <br />right?
This is a comment on Maniero’s response, but it’s too big to fit in one comment. His answer is absolutely correct for today, but it does not explain why there is this confusion between forms. He…
-
18
votes4
answers4731
viewsA: How to check if the first four characters of a string match 'www.'?
The code looks better (more readable) if you look at the 4 characters at once: if(string.substr(0, 4) === "www.") { } Or if(string.substring(0, 4) === "www.") { } The two methods do basically the…
-
5
votes4
answers428
viewsA: Make SELECT return data in default language when no translation can be found
If I understand correctly, you have no guarantee of which ID will be returned. It’s hard to give an accurate answer without knowing more about your bank, but I would make a JOIN for content in each…
mysqlanswered bfavaretto 64,705 -
3
votes3
answers762
viewsA: How to return the number of the input position within a form?
Your nested loops are redefining the value of i and creating confusion. The correct thing in this case would be to create a closure that captures the current value of the most external loop, so you…
javascriptanswered bfavaretto 64,705 -
6
votes2
answers1969
viewsA: How to make a CSS animation stop in the last state?
There is an experimental property called animation-fill-mode which defines "how a CSS animation should apply the styles to the target before and after its execution". The value forwards determines…
-
9
votes4
answers58562
viewsA: Css comments with // instead of /* */
Complementing the other answers: this example does not give problem because it is at the beginning of the line, but at the end can give a problem. For example: div { background-color: cyan;…
-
4
votes2
answers89
viewsA: How to find a value in several fields
You can use a IN "otherwise" (than normally used): ... WHERE '2345-6789' IN (tel1, tel2, tel3)
-
6
votes2
answers125
viewsA: Give Alert after typing the word "pass"
My solution is similar to Guilherme Bernal’s, but clears the keystroke buffer if you take too long between a letter and another: var intervaloMaximo = 2000; var timestamp = Date.now(); var palavra =…
-
2
votes2
answers60
viewsA: Add methods to plugin namespace without selector
Your plugin has a chaining problem (chaining) of jQuery objects. What the documentation recommends is that your plugin always returns this (if it always applies to collections of only 1 object), or…
-
9
votes3
answers2156
viewsA: The 4th edition of the Javascript book: Is the Definitive Guide still a reliable source?
That issue must be quite out of date (I say "should" because I didn’t read it). It is based on version 3 of the language standard (Ecmascript 3, "Javascript 1.5" is this plus some exclusive Mozilla…
javascriptanswered bfavaretto 64,705 -
3
votes2
answers685
viewsA: How many lines did a database query return (Cake PHP)?
I suppose you’re holding the result in a variable, right? Something like that: $comentarios = $this->Post->Comment->find('all', array('conditions' => array('Comment.post_id' =>…
-
3
votes1
answer509
viewsA: Take combobox selectedIndex and switch to input?
You can fill in a hidden field: <input type="hidden" name="cbi"> function desc(){ var i = document.form2.cb.selectedIndex; document.form2.cbi.value = document.form2.cb.selectedIndex; }…
javascriptanswered bfavaretto 64,705 -
7
votes1
answer67
viewsA: How to pass argument to Object prototyped with prototype?
In your first example, nothing is defined in the prototype. The properties and method are defined directly in the instance created when you call new Biscoito(...). In the second example have the…
-
2
votes4
answers453
viewsA: Get most used words from a string
The answers of Sergio and Zuul probably have better performance, but follows a didactic solution that uses strtok to break the text into words, and count manually. This solution is case-insensitive.…
-
4
votes2
answers197
viewsA: How to set an element via jQuery/Javascript?
Define what is inside as the innerHTML (or textContent) tag: li.innerHTML = 'lang: pt_BR';
-
5
votes1
answer3536
viewsA: How to manipulate the position of a div
I won’t give you the answer of how to move two Divs in opposite directions, but here’s the basics of how to manipulate an HTML element. Consider this div: <div id="minhaDiv"></div> In…
javascriptanswered bfavaretto 64,705 -
2
votes2
answers1712
viewsA: How to Commit Deleted Files from Local Project?
I went through this problem right now, and found in the OS in English a solution that worked for me: git ls-files --deleted -z | xargs -0 git rm Source: Reply by Mark Longair to Delete files from…
gitanswered bfavaretto 64,705 -
2
votes4
answers420
viewsA: CSS, firefox input shows blank text
Firefox is respecting the box-sizing that you indicated. When you use border-box, the height of the element includes edges and padding. Technically you even exceeded the set height, and Firefox is…
-
5
votes2
answers350
viewsA: What is the purpose of unset as cast in PHP?
What is the purpose of this implementation? Like explained by Pope Charlie, it uses type conversion syntax to generate a value null. In language it is possible to do casting for any primitive type…
-
9
votes2
answers1484
viewsA: Compareto: Comparison method violates its general Contract!
According to the interface documentation (in free translation): The implementation must also ensure that the relationship is transitive: (x.compareTo(y)>0 && y.compareTo(z)>0) implies…
-
3
votes1
answer41
viewsA: Index value not being recognized correctly
The .index() returns the index of the requested element in relation to the parent element. In your case, all links will have zero index. I think you want the element index .link which contains the…
-
6
votes1
answer50
viewsA: Doubt how to jump 7 in 7 in the ids of own onItemClickListener android
Sounds like a case for the operator of rest %: // Se o ID for múltiplo de 7... // Em outras palavras, se o resto da divisão por 7 for zero... if(id_item_titulo % 7 == 0) { // ... }…
-
5
votes1
answer326
viewsA: JSON generated by json_encode gives error in character "{"
Everything indicates that your PHP is sending something else before the {. Check that your file is saved as UTF-8 with BOM (byte-order Mask), as BOM would invalidate JSON. To check, open in an…
-
9
votes2
answers2303
viewsA: How to check if an answer (date) is a json
The method parseJSON jQuery raises an exception if JSON is not valid. Therefore: var obj; try { obj = $.parseJSON(response); // use o JSON aqui } catch(ex) { // trate o erro aqui }…
-
1
votes1
answer1137
viewsA: Take data from a specific cakephp field
It is not clear in which situation you want to take this data. If it is the value of the field after sending the form, this is usually done in the Controller: $usuario =…
-
4
votes5
answers1089
viewsA: Problem with <link rel="stylesheet/Less" ... >
You need lower and include the Javascript LESS interpreter for this to work: <script src="less.js" type="text/javascript"></script> Reference: http://lesscss.org/#client-side-Usage…