|
Okay.
- 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.
- 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.
- 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.
- 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.
|
|
|
|
|
Thanks for the great explanation!
Nathan Minier wrote: <script src=".../.../signalr.js>
It's up above as
"
I saw this and It's supposed to be an auto-generated proxy. I looked for the SignalR script but couldn't find it.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
modified 28-Feb-17 16:53pm.
|
|
|
|
|
I've never played with the SignalR templates so I'm not sure why it wouldn't be building that portion.
Drop the HTML, let's take a look.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
How do I incorporate Review Markup Schemas in a WordPress website? Thank you.
|
|
|
|
|
There are a lot of plugins with related titles, but I recommend to do it manually
|
|
|
|
|
up what i need is a lots of plugins, for it.
|
|
|
|
|
I'm very new to web development, so forgive my ignorance...
I've got a grid on a page, and it loads fine on startup. I then receive an event from a SignalR service. I want to reload the grid at this point. Here's my controller:
public class HomeController : Controller
{
private IDataAccess _dal;
private DashboardClientProxy _dashboardProxy;
private bool _isConnected = false;
public HomeController()
{
_dal = new DataAccess();
_dashboardProxy = new DashboardClientProxy();
_dashboardProxy.ResultsAdded += _dashboardProxy_ResultsAdded;
try
{
_dashboardProxy.Connect();
}
catch (Exception e)
{
throw e;
}
}
public ActionResult Index()
{
var data = _dal.GetDashboardInfos(new DashboardInfoQueryArgs());
return View(data);
}
private void _dashboardProxy_ResultsAdded(object sender, EventArgs data)
{
RedirectToAction("Index", "HomeController");
}
}
I thought that by calling "RedirectToAction("Index", "HomeController") that the Index method would be run again, yet it doesn't work.
What am I doing wrong here?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
RedirectToAction returns a result to the client telling it to make a new request to the specified action. But it only works in response to a request from the client.
If it fires at all, your event is being fired on a background thread, long after the index view has been rendered. The client is no longer connected to your server, and is not waiting for a response.
But I suspect it will never fire. I believe the default is for MVC to create a new instance of your controller class for each request, and dispose of it once the request has completed. Since the controller owns the object which raises the event, there will be no reachable references to the instance, so both the controller and the proxy will be deleted.
Instead, you'll need to have the client connect directly to your SignalR hub in Javascript. It will need to listen for the event, and when it receives the event, either reload the page, or make an AJAX request to reload just the grid.
ASP.NET SignalR Hubs API Guide - JavaScript Client | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I am using MVCGrid.Net.
From what I can see from their documentation the GridColum doesn't have a width property.
Anyone used this grid before? Any way to set a column's width?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
What about:
CellCssClassExpression Func<T1, GridContext, string> Use this to specify a custom css class based on data for the current cell
I thought CSS allowed you to specify width of a field.
|
|
|
|
|
Hello.,
Here's my thing, I have a website that was created with MS Publisher and I used to modify and upload the information through core ftp lite. This website gets the job done with the pictures and information but now I need something more up to date and dynamic. I bought a hosting plan to Hostgator and was trying to use the wordpress and joomla thing but it seems a bit complicated and it's not as easy as I thought it would be when I created a free website in WIX. So I'd like to know what options do I have to build the website and what software is recommended to edit and upload all the stuff. My budget is limited now and my business is not that big so I don't think I could hire a Pro in the matter.
Thanks.
|
|
|
|
|
Did you know WordPress and Joomla etc come shipped with some good looking themes by default? Just go the Appearance or Theme tabs and you can find thousands of themes that can be applied to your website in seconds. Secondly, you can get access to the content of the template as well, if you want to update or modify the templates.
So, even if you are not a pro, or can't afford one you can still get the website's theme up to date by selecting from a lot of the available ones on the gallery.
As for the deployment options, WordPress and Joomla do provide an online editor for you to edit your content from the control panel. Otherwise, there is a tool by Microsoft WebMatrix, that is provided free of cost and is fully capable of editing PHP websites. Visual Studio Code is also available, if you are somewhat happy with editing of the application yourself. Otherwise, they got your back — and their hands in your pocket.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
|
Could you please suggest me how i can make this concept ,if time1<time2, so="" it="" will="" add="" +1="" in="" time1,="" i="" explain="" this="" example="" suppose="" the="" time2="" is="" 07:40="" am="" and="" time1="" 1:00="" now="" become="" 25="" or="" 2:00="" 26="" but="" if="" value="" 07:41="" work="" as="" a="" normal="" .
<pre="" lang="Javascript">
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<div ng-app="myapp">
Time1 :<br><input type="time" id="time1" name="time1" ng-model="time1" placeholder="HH:mm" required /><br>
<br>
Time2 :<br><input type="time" id="time2" name="time2" ng-model="time2" placeholder="HH:mm" required />
<p> Your Time is ans is {{(time1-time2)| correcttime | date: 'HH:mm': 'UTC'}} </p>
</div>
<script>
var app = angular.module('myApp', []);
app.filter('correcttime', function() {
if {
time1>24;
time1=+1;
}
else if {
time1=time2;
time1-time2==0;
}
else{
time1-time2;
}
return function(num) { return Math.abs(num); }
});
</script>
</body>
</html>
modified 16-Feb-17 20:32pm.
|
|
|
|
|
I am not an expert in AngularJS, but looking at the following code:
if {
time1>24;
time1=+1;
}
else if {
time2=time2;
time1==0;
}
else{
time1-time2;
}
I would be happy to read an explanation of why my assumptions are wrong.
|
|
|
|
|
I was going to comment on the lack of a controller, the capitalization issue, and the malformed conditional statements, but no real point until the core logic is sorted.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
|
does any body know any opensource mvc discussion forum/board to include in existing mvc project?
|
|
|
|
|
|
I'm not sure why you were downvoted since this is an area to discuss topics. Upvoted to counter.
And no, I don't know of any.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I want to use Google Translate in a new website I am developing. I have created the code I want on the Goggle site and it works very well when I run it in the website.
The only problem I have is that it won't position itself where I want it. I am trying to place it at the bottom right hand corner of my site alongside the Copyright notice under the site footer.
I am using W3.CSS to provide me responsiveness and have created the following code.
<div class="w3-display-container w3-row">
<div class="w3-col">
</div>
<div class="w3-col w3-center w3-small">
Copyright statement appears here
</div>
<div class="w3-col w3-right w3-top">
<p>Translate this page:</p>
<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({ pageLanguage: 'en' }, 'google_translate_element');}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div>
</div>
</div>
I've tried recoding this a number of different ways and it hasn't yet appeared where I want it. It has appeared above the header area, in the header area and under the header area on both the right and left of the webpage.
Any help would be most welcome.
Oh, by the way, Bing Translate behaves in a similar way.
|
|
|
|
|
The div with id "google_translate_element" is the one which shows the translator button. So style that only. Keep it on the footer of your site the add the style like this -
#google_translate_element
{
float:right:
}
|
|
|
|
|
Thanks for your reply
It does indeed float the element to the right but it is still positioned at the top of the Header area when I open the web page. When I scroll the page, the element doesn't move its position on the screen. It just scrolls down the webpage maintaining a fixed position relative to the monitor not the web page. I just don't understand this at all ???
|
|
|
|
|
I think postion:fixed is getting applied to the div.Since you don't want it change it to absolute one by by replacing the html code by this:
<div class="w3-col w3-right w3-top" style="position:relative">
<p>Translate this page:</p>
<div id="google_translate_element" style="positon:absolute;top:10px;left:10px"></div>
<!--
</div>
</div>
By using the above code the translator div will be place 10 pixels from the top and 10pixels from the left of its parent which is the div with class "w3-col w3-right w3-top".
You can change the top and left values to adjust it more.
|
|
|
|
|
I have finally got it to a position I can live with. It is on the left hand side of the web page in the area I want it rather than the right hand side of that area. The code I have used is as follows:
<div class="w3-col" style="position:absolute; top:10px; left:10px" id="google_translate_element">
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({ pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false }, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div>
I really don't know what part of the code made it work this way, but hey, who cares - it works. The only problem is that this is a fixed position and therefore is not responsive on mobiles.
Many thanks for your help.
|
|
|
|