Click here to Skip to main content
15,845,912 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: PHP WITH BIOMETRIC Pin
Member 1178652210-Mar-17 8:12
Member 1178652210-Mar-17 8:12 
QuestionPHP MYSQL UPDATE ISSUE Pin
Member 117865228-Mar-17 2:29
Member 117865228-Mar-17 2:29 
AnswerRe: PHP MYSQL UPDATE ISSUE Pin
ZurdoDev10-Mar-17 7:54
professionalZurdoDev10-Mar-17 7:54 
QuestionMake up of a single web with react Pin
Orlando.Net1-Mar-17 9:29
Orlando.Net1-Mar-17 9:29 
AnswerRe: Make up of a single web with react Pin
Nathan Minier2-Mar-17 3:32
professionalNathan Minier2-Mar-17 3:32 
QuestionRe: Make up of a single web with react Pin
ZurdoDev10-Mar-17 7:55
professionalZurdoDev10-Mar-17 7:55 
QuestionJavaScript - Help Me Understand Pin
Kevin Marois28-Feb-17 8:54
professionalKevin Marois28-Feb-17 8:54 
AnswerRe: JavaScript - Help Me Understand Pin
Nathan Minier28-Feb-17 10:38
professionalNathan Minier28-Feb-17 10:38 
Okay.
  1. The mix of concerns is largely based on the fact that this block of code is bootstrapping an event handler (proxy.client.broadcastMessage()) and a callback ($.connection.hub.start().done()) that bootstraps another event handler.
  2. The dollar sign, when used as it is in this example, is often a reference to jQuery. The key indicator is the selector syntax: $('#thing'), $('.stuff'), etc. Where you see it used as an object that's because it is one. Welcome to the joy of frameworks.
  3. Here's the fun part: in JavaScript everything is an object, to include functions. The nested functions simply represent that a return value or process is required at a certain point. All functions in JS can be trivially assigned a function pointer; in fact that's the way that most functions are handled automatically when they are assigned as arguments.
At any rate, that's a perfectly normal construct, and is appropriate in any place where you want to pass a value that may not be resolved when you call the outer function.
  1. As noted earlier, the "$" object is jQuery and any extension loaded for it. Think of it like a class library; somewhere before this code execution there was a <script src=".../.../jQuery.js"></script> and a <script src=".../.../signalr.js"></script>. You can safely think of that as a class library import.
So what does this snippet do?

Creates a closure that will be executed when jQuery is loaded, snagging the value of chatHub which is likely loaded as part of a jQuery plugin.

Adds an event handler that informs the hub of what to do when an incoming message is received. You'll notice some GUI logic there.

Bootstraps the local input items.

Once the hub has loaded, define an event handler that will allow the user to send a message.

That's it.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli


modified 1-Mar-17 8:37am.

GeneralRe: JavaScript - Help Me Understand Pin
Kevin Marois28-Feb-17 11:45
professionalKevin Marois28-Feb-17 11:45 
GeneralRe: JavaScript - Help Me Understand Pin
Nathan Minier1-Mar-17 1:58
professionalNathan Minier1-Mar-17 1:58 
QuestionSchemas Pin
Member 1302472026-Feb-17 6:53
professionalMember 1302472026-Feb-17 6:53 
AnswerRe: Schemas Pin
BrunoFaitalaas6-Mar-17 1:17
BrunoFaitalaas6-Mar-17 1:17 
AnswerRe: Schemas Pin
camillebo16-Jun-17 14:35
camillebo16-Jun-17 14:35 
QuestionMVC Refresh A Grid Pin
Kevin Marois22-Feb-17 11:51
professionalKevin Marois22-Feb-17 11:51 
AnswerRe: MVC Refresh A Grid Pin
Richard Deeming23-Feb-17 5:04
mveRichard Deeming23-Feb-17 5:04 
QuestionMVCGrid.Net Column Width Pin
Kevin Marois21-Feb-17 14:31
professionalKevin Marois21-Feb-17 14:31 
QuestionRe: MVCGrid.Net Column Width Pin
Richard MacCutchan21-Feb-17 23:10
mveRichard MacCutchan21-Feb-17 23:10 
QuestionWebsite Build Help!! Please Pin
Member 1300832617-Feb-17 16:22
Member 1300832617-Feb-17 16:22 
AnswerRe: Website Build Help!! Please Pin
Afzaal Ahmad Zeeshan17-Feb-17 22:09
professionalAfzaal Ahmad Zeeshan17-Feb-17 22:09 
SuggestionRe: Website Build Help!! Please Pin
Richard Deeming18-Feb-17 2:22
mveRichard Deeming18-Feb-17 2:22 
QuestionAngular JS code Not work Pin
Member 1300557216-Feb-17 5:44
Member 1300557216-Feb-17 5:44 
AnswerRe: Angular JS code Not work Pin
Richard MacCutchan16-Feb-17 6:37
mveRichard MacCutchan16-Feb-17 6:37 
GeneralRe: Angular JS code Not work Pin
Nathan Minier16-Feb-17 7:33
professionalNathan Minier16-Feb-17 7:33 
GeneralRe: Angular JS code Not work Pin
Richard MacCutchan16-Feb-17 8:45
mveRichard MacCutchan16-Feb-17 8:45 
QuestionMvc Discussion forum Pin
pankajkrgupta24-Jan-17 19:51
pankajkrgupta24-Jan-17 19:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.