<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jquery &#8211; SMsoft &#8211; informatica e dintorni</title>
	<atom:link href="https://blog.smsoft.it/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.smsoft.it</link>
	<description>consigli settimanali su MacOS, GNU/Linux ed Open Source</description>
	<lastBuildDate>Tue, 06 Sep 2016 08:30:35 +0000</lastBuildDate>
	<language>it-IT</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=91739</generator>
	<item>
		<title>Le funzioni più diffuse di jQuery convertite in Vanilla JS (ovvero native)</title>
		<link>https://blog.smsoft.it/2016/09/06/le-funzioni-piu-diffuse-jquery-convertite-vanilla-js-ovvero-native/</link>
					<comments>https://blog.smsoft.it/2016/09/06/le-funzioni-piu-diffuse-jquery-convertite-vanilla-js-ovvero-native/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 06 Sep 2016 08:30:35 +0000</pubDate>
				<category><![CDATA[Html e PHP]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[vanilla]]></category>
		<guid isPermaLink="false">http://blog.smsoft.it/?p=3494</guid>

					<description><![CDATA[Ormai in molti sono abituati ad utilizzare jQuery per qualsiasi manipolazione DOM o chiamata ajax, ma le stesse operazioni possono essere fatte in Vanilla JS (ovvero in modo nativo con Javascript) e quindi in modo più veloce e senza dover utilizzare librerie esterne. Vediamone alcune. Gestione degli eventi // jQuery $(document).ready(function() { // code }) ... <a title="Le funzioni più diffuse di jQuery convertite in Vanilla JS (ovvero native)" class="read-more" href="https://blog.smsoft.it/2016/09/06/le-funzioni-piu-diffuse-jquery-convertite-vanilla-js-ovvero-native/" aria-label="Per saperne di più su Le funzioni più diffuse di jQuery convertite in Vanilla JS (ovvero native)">Leggi tutto</a>]]></description>
										<content:encoded><![CDATA[<p>Ormai in molti sono abituati ad utilizzare jQuery per qualsiasi manipolazione DOM o chiamata ajax, ma le stesse operazioni possono essere fatte in Vanilla JS (ovvero in modo nativo con Javascript) e quindi in modo più veloce e senza dover utilizzare librerie esterne. Vediamone alcune.</p>
<h5>Gestione degli eventi</h5>
<p><code lang="js">// jQuery<br />
$(document).ready(function() {<br />
  // code<br />
})</p>
<p>// Vanilla<br />
document.addEventListener('DOMContentLoaded', function() {<br />
  // code<br />
})</code></p>
<p><code lang="js">// jQuery<br />
$('a').click(function() {<br />
  // code…<br />
})</p>
<p>// Vanilla<br />
[].forEach.call(document.querySelectorAll('a'), function(el) {<br />
  el.addEventListener('click', function() {<br />
    // code…<br />
  })<br />
})</code></p>
<h5>Selettori</h5>
<p><code lang="js">// jQuery<br />
var divs = $('div')</p>
<p>// Vanilla<br />
var divs = document.querySelectorAll('div')</code></p>
<p><code lang="js">// jQuery<br />
var newDiv = $('</p>
<div/>')</p>
<p>// Vanilla<br />
var newDiv = document.createElement('div')</code></p>
<h5>Attributi</h5>
<p><code lang="js">// jQuery<br />
$('img').filter(':first').attr('alt', 'My image')</p>
<p>// Vanilla<br />
document.querySelector('img').setAttribute('alt', 'My image')</code></p>
<h5>Classi</h5>
<p><code lang="js">// jQuery<br />
newDiv.addClass('foo')</p>
<p>// Vanilla<br />
newDiv.classList.add('foo')</code></p>
<p><code lang="js">// jQuery<br />
newDiv.toggleClass('foo')</p>
<p>// Vanilla<br />
newDiv.classList.toggle('foo')</code></p>
<h5>Manipolazione</h5>
<p><code lang="js">// jQuery<br />
$('body').append($('</p>
<p/>'))</p>
<p>// Vanilla<br />
document.body.appendChild(document.createElement('p'))</code></p>
<p><code lang="js">// jQuery<br />
var clonedElement = $('#about').clone()</p>
<p>// Vanilla<br />
var clonedElement = document.getElementById('about').cloneNode(true)</code></p>
<p><code lang="js">// jQuery<br />
$('#wrap').empty()</p>
<p>// Vanilla<br />
var wrap = document.getElementById('wrap')<br />
while(wrap.firstChild) wrap.removeChild(wrap.firstChild)</code></p>
<h5>Transversing</h5>
<p><code lang="js">// jQuery<br />
var parent = $('#about').parent()</p>
<p>// Vanilla<br />
var parent = document.getElementById('about').parentNode</code></p>
<p><code lang="js">// jQuery<br />
if($('#wrap').is(':empty'))</p>
<p>// Vanilla<br />
if(!document.getElementById('wrap').hasChildNodes())</code></p>
<p><code lang="js">// jQuery<br />
var nextElement = $('#wrap').next()</p>
<p>// Vanilla<br />
var nextElement = document.getElementById('wrap').nextSibling</code></p>
<h5>Ajax GET</h5>
<p><code lang="js">// jQuery<br />
$.get('//example.com', function (data) {<br />
  // code<br />
})</p>
<p>// Vanilla<br />
var httpRequest = new XMLHttpRequest()<br />
httpRequest.onreadystatechange = function (data) {<br />
  // code<br />
}<br />
httpRequest.open('GET', url)<br />
httpRequest.send()</code></p>
<h5>Ajax POST</h5>
<p><code lang="js">// jQuery<br />
$.post('//example.com', { username: username }, function (data) {<br />
  // code<br />
})</p>
<p>// Vanilla<br />
var httpRequest = new XMLHttpRequest()<br />
httpRequest.onreadystatechange = function (data) {<br />
  // code<br />
}<br />
httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')<br />
httpRequest.open('POST', url)<br />
httpRequest.send('username=' + encodeURIComponent(username))</code></p>
<h5>Ajax JSONP</h5>
<p><code lang="js">// jQuery<br />
$.getJSON('//openexchangerates.org/latest.json?callback=?', function (data) {<br />
  // code<br />
})</p>
<p>// Vanilla<br />
function success(data) {<br />
  // code<br />
}<br />
var scr = document.createElement('script')<br />
scr.src = '//openexchangerates.org/latest.json?callback=formatCurrency'<br />
document.body.appendChild(scr)</code></p>
<p>enjoy!</p>
<p>(<a href="https://gist.github.com/liamcurry/2597326" target="_blank" rel="noopener noreferrer">fonte</a>)</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.smsoft.it/2016/09/06/le-funzioni-piu-diffuse-jquery-convertite-vanilla-js-ovvero-native/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>jquery-bootgrid: come gestire la larghezza delle colonne</title>
		<link>https://blog.smsoft.it/2016/06/21/jquery-bootgrid-gestire-la-larghezza-delle-colonne/</link>
					<comments>https://blog.smsoft.it/2016/06/21/jquery-bootgrid-gestire-la-larghezza-delle-colonne/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 21 Jun 2016 09:30:51 +0000</pubDate>
				<category><![CDATA[Html e PHP]]></category>
		<category><![CDATA[bootgrid]]></category>
		<category><![CDATA[data-header-css-class]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery-bootgrid]]></category>
		<guid isPermaLink="false">http://blog.smsoft.it/?p=3435</guid>

					<description><![CDATA[jquery-bootgrid è un buon sostituto per datatables.net per la gestione delle tabelle con contenuti da caricare tramite ajax, senza dover ricaricare la pagina. Sicuramente non offre tutte le caratteristiche del più famoso che ho già citato, ma è molto leggero e fa quello per cui è stato scritto. Oggi non vi parlo di come implemetarlo ... <a title="jquery-bootgrid: come gestire la larghezza delle colonne" class="read-more" href="https://blog.smsoft.it/2016/06/21/jquery-bootgrid-gestire-la-larghezza-delle-colonne/" aria-label="Per saperne di più su jquery-bootgrid: come gestire la larghezza delle colonne">Leggi tutto</a>]]></description>
										<content:encoded><![CDATA[<p><a href="https://github.com/rstaib/jquery-bootgrid" target="_blank" rel="noopener noreferrer">jquery-bootgrid</a> è un buon sostituto per datatables.net per la gestione delle tabelle con contenuti da caricare tramite ajax, senza dover ricaricare la pagina.</p>
<p>Sicuramente non offre tutte le caratteristiche del più famoso che ho già citato, ma è molto leggero e fa quello per cui è stato scritto.</p>
<p>Oggi non vi parlo di come implemetarlo (ci sono delle <a href="http://www.jquery-bootgrid.com/Examples" target="_blank" rel="noopener noreferrer">demo nel sito ufficiale</a>), ma di come gestirne alcune caratteristiche, non ben documentate.</p>
<p>Ad esempio, è possibile gestire la larghezza delle varie colonne, associando le classiche classi di bootstrap, ma la documentazione non offre una guida adeguata.</p>
<p>Veniamo al sodo. Per gestire la larghezza di una colonna, si può usare l&#8217;attributo <strong>data-header-css-class</strong> con la classe relativa alla larghezza (es <strong>col-sm-2</strong>).</p>
<p>Questo un esempio:</p><pre class="urvanov-syntax-highlighter-plain-tag"><table id="grid-data" class="table table-condensed table-hover table-striped">
    <thead>
      <tr>
        <th data-column-id="tots">Totali nel DB</th>
        <th data-column-id="remains">Da aggiornare</th>
        <th data-column-id="errors">Errori nel DB</th>
        <th data-column-id="rows">Rows Tot/Add/Upd/Err</th>
        <th data-column-id="tempo">Tempo</th>
        <th data-column-id="ts" data-visible="false" >Ts</th>
        <th data-column-id="tsi" data-header-css-class="col-sm-2" data-order="desc">TS</th>
      </tr>
    </thead>
  </table></pre><p>In questo esempio, la colonna <strong>tsi</strong> avrà larghezza <strong>col-sm-2</strong>.</p>
<p>Ricapitolando, a differenza di quanto scritto nella documentazione, il nome degli attributi non è nel formato:</p><pre class="urvanov-syntax-highlighter-plain-tag">data-camelCase=</pre><p>bensì nel formato:</p><pre class="urvanov-syntax-highlighter-plain-tag">data-camel-case=</pre><p></p>
<p>Questi alcuni tra gli attributi più utili:</p><pre class="urvanov-syntax-highlighter-plain-tag">data-column-id // non data-id come indica la documentazione
    data-identifier
    data-converter
    data-header-align // [sic], data-headerAlign fallisce in JQuery 1.5+
    data-css-class // come sopra
    data-header-css-class // come sopra
    data-formatter
    data-order
    data-searchable
    data-sortable
    data-visible
    data-visible-in-selection // come sopra
    data-width</pre><p></p>
<p>enjoy!</p>
<p>(<a href="https://github.com/rstaib/jquery-bootgrid/issues/239" target="_blank" rel="noopener noreferrer">fonte</a>)</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.smsoft.it/2016/06/21/jquery-bootgrid-gestire-la-larghezza-delle-colonne/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
