Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 10th, 2012, 04:22 PM
Registered User
 
Join Date: Jul 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Page 387 - jQuery doesn't seem to have these methods...

I've tried re-entering the code several times over, and even tried copy-pasting it directly from an earlier post by Imar. This is how I have my code looks:

Code:
<script type="text/javascript">
$(function()
{
  $(':input[type=text], textarea').each
  (
    function()
    {
      var newText = 'Please enter your ' + $(this).parent().prev().text().toLowerCase().trim();
      $(this).attr('value', newText);
    }).one('focus', function()
    {
      this.value = '', this.className = ''
    }).addClass('Watermark').css('width', '300px');
  });
</script>
The trouble does not seem to be with typos, but that jQuery, or maybe at least Intellisense, don't agree with this codeblock.

in the line $(this).parent().prev().text(),
.toLowercase() doesn't show up in Intellisense.

inside of the .one('focus', function(){,
this does not have the .value or .className methods in Intellisense


Additionally, in the section Miscellaneous jQuery Functionality, I was never able to get the .innerHTML property.


I'm using the copy of jQuery from the code download, jquery-1.4.1.min.js, and I'm using Visual Studio 2010.
 
Old July 10th, 2012, 10:10 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I think this is all by design; value, innerHTML and className are all JavaScript properties, and not jQuery methods. In addition, IntelliSense doesn't really know what type of object "this" represents. As such, it cannot present proper IntelliSense suggestions. This is caused by the weakly typed nature of JavaScript where properties like value only really exist at runtime.

I take it the example runs fine in the browser?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old July 11th, 2012, 12:17 PM
Registered User
 
Join Date: Jul 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ah, that makes sense, that's very helpful to know. I'm so used to trusting in Intellisense, that is, if what you're expecting isn't showing up in Intellisense...you made a mistake somewhere.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Few Questions related to jquery code on p.387.. Tulsi BOOK: Beginning ASP.NET 4 : in C# and VB 2 April 12th, 2012 01:28 PM
Page Methods (Ch 10, p 358) jlransford BOOK: Beginning ASP.NET 4 : in C# and VB 4 December 16th, 2011 08:28 PM
Page Methods TeaDrinkingGeek BOOK: Beginning ASP.NET 4 : in C# and VB 2 March 7th, 2011 07:05 AM
Chapter 11 page 386,387 tariq BOOK: Beginning ASP.NET 4 : in C# and VB 2 August 30th, 2010 04:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.