Welcome to Idea R | Branding - Web Agency - Digital Strategies
Switch to the mobile layout

      Idea R - Plan your visual communication at 360°
  • HomeHome
  • About UsAbout Us
  • ContactsContacts

Blog

Take a software geek from the 80s, add a new generation graphic designer and dilute with a longtime marketing strategist. Shake vigorously and you'll get the Idea R's blog.

Change language... italiano

You may be interested in

Tracking Facebook likes with Google Analytics, the real solution!

Tracking Facebook likes with Google Analytics, the real solution!

How to monior Facebook interaction of your customers and analyze their impact on your conversions

How to dramatically increase social media LIKEs to your web site

Here's a free download that I created some time ago. It's a good tool for increasing engagement, but use with caution.

Last published

Case study: branding and marketing for a magician

Case study: branding and marketing for a magician

Singular case study in the world of illusionism. See how we have created a brand and a web marketing campaign with exceptional results.

Can engineering industry sponsor art without going off topic?

How to design a page in an exhibition catalog of Biennale in Venice, for a customer who apparently has nothing to do with art.

Most popular

Lazy loading and the SEO problem, solved!

Lazy loading and the SEO problem, solved!

The best SEO solution to index your dynamically loaded contents, no more compromises!

Case study: TAV Engineering, branding for B2B services

How to create a brand that keeps distance from the cold and aseptic image of the metal industry, focusing instead on the human aspect.

Editor's pick

Mental marketing secret #1: the fake compromise

Mental marketing secret #1: the fake compromise

Can mentalism influence marketing? As a marketing professional and a long term magician, I will reveal you some tricks.
newsletter

Stay informed on digital strategies

My reviews on the subject...

I have many books on web design, the list is quite long, especially if I have to include all those which deal strictly to programming. I shall therefore refer you to some interesting texts. Don't Make Me Think! is the most famous book on usability, you can not miss it if you're involved in web design.

RSS feed

jQuery: come lanciare e gestire gli eventi personalizzati

Published on 11/22/2012
Categories: Web Design
jQuery: come lanciare e gestire gli eventi personalizzati

Avevamo già visto in un articolo precedente come gestire gli eventi JavaScript.
jQuery semplifica ma soprattutto uniforma il motore di eventi di JavaScript con 2 semplici metodi: bind() per sottoscriversi ad un evento e trigger() per lanciarlo.

Gli eventi non sono però solo una prerogativa degli oggetti standard DOM (Document Object Model), anche i vostri oggetti possono lanciare eventi, persino se non hanno nulla a che fare con il DOM.
In linea generale con jQuery ci si sottoscrive agli eventi usando le seguente forma

$(mySelector).bind('click', function(event){...});

o la forma più contratta

$(mySelector).click(function(event){...});

Come anticipato ci si può sottoscrivere anche ad eventi personalizzati, con

$(mySelector).bind('mycustomevent', function(event){...});

che a loro volta verranno lanciati dall'oggetto personalizzato con

$(mySelector).trigger('mycustomevent');

Domanda: se volessi passare delle informazioni all'event handler al momento del binding?
Risposta: si può passare qualsiasi informazione specificandola nell'istruzione bind che poi l'event handler recupererà dalla proprietà data dell'oggetto event.

// Use myCustomData to hold bind-time data
$(mySelector).bind('mycustomevent', myCustomData, function(event)
{
    ...

    // event.data contains myCustomData
    var myData = event.data;

    ...
});

Altra domanda: e se volessi passare delle informazioni all'event handler al momento del lancio dell'evento?
Risposta: si definisce semplicemente un parametro aggiuntivo nell'event handler.

// Use myParam to hold trigger-time data
$(mySelector).bind('mycustomevent', function(event, myParam){...});
...
$(mySelector).trigger('mycustomevent', 'this is the trigger-time parameter');

See also

Eventi JavaScript? Che confusione!

Vediamo di fare un po' di ordine sul sistema di eventi JavaScript e di capire quale usare a seconda della situazione.

You are the reader number 4,870.

Comments

comments powered by Disqus
Creative Commons License

Photographies, videos, graphics and texts by Idea R are licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

Previous article

Previous article

An App to see Amsterdam through Anne Frank's eyes

Next article

3 methods to detect mobile devices in ASP.NET

Next article
  • Visual Communication, Art DirectionVisual Communication, Art Direction
  • Apps, Cloud, Mobile, Software DesignApps, Cloud, Mobile, Software Design
  • Digital StrategiesDigital Strategies
  • BlogBlog
Touching finger
RSS feed
Blog

Scroll to top