Jump to content
Larry Ullman's Book Forums

markifornia

Members
  • Posts

    112
  • Joined

  • Last visited

markifornia's Achievements

Newbie

Newbie (1/14)

3

Reputation

  1. This one's a simple question, I am just trying to figure out where the supplementary markup code for the code is? I am fine coding this myself though, I was just making sure otherwise I will also check the source files provided on Larry Ullman's site. Figure 8.7/8.8 displays the form on reporting events on page 292. Thanks, Mark
  2. Thanks Hartley, could very well be the reason why on page 287, both events are passed to the function. U.addEvent(U.$('comments'), 'keyup', limitText); U.addEvent(U.$('comments'), 'change', limitText); Page 288 goes into detail about accessibility with introducing a concept known as "pairing events". I guess the above is similar to the concept. <a href="somepage.html" id="link">Some Text</a> // javascript: addEvent(document.getElementById('link'), 'mouseover', doSomething); addEvent(document.getElementById('link'), 'focus', doSomething); I guess this makes some sense now.
  3. This chapter discusses a topic on keyboard events. I have provided links to my dev website. On page 284, the "change" event is added to the U.addEvent method. U.addEvent(U.$('comments'), 'change', limitText); http://www.sandiegowebcreative.com/text.html On page 284, the "keyup" event is added to the U.addEvent method. U.addEvent(U.$('comments'), 'keyup', limitText); http://www.sandiegowebcreative.com/text2.html I don't notice the difference between the two. I receive the same results from my browser, or I may not be noticing that which is obvious (or not as obvious?) Anyone come across this?
  4. You've both pointed out some advanced concepts just beyond me in my learning process, but I see both ways working. I've built some forms just using PHP and Javascript where I'll have the form dynamically load the form (including javascript validation routines), and then have a noscript version of the form handled by PHP (the fallback, with validations). So here, I have done the same thing - two versions - let me tell you though, this method has worked successfully against spam bots. My forms are completely CAPTCHA free. So I drew a parallel to my approach. But here I am learning how to build ajax applications. I'm not looking at the task lazily but just imagine a large web application. My first thought is that if I have many pages, I would have to build an ajax and a non ajax version for each one. It does make sense to do so, it is not like every page should be dependent on ajax right. Ajax is also useful in updating just a specific part of the page (such as a poll). I have not built a large ajax web application, so I may have no say in this at this point. As Larry confirmed, two versions is the best way to go about it as I drew that parallel with my experience with building contact forms. Assuming ajax driven forms aren't used heavily throughout the web application, which I think is often true than not (just a guess). I guess when I thought about this approach, I started thinking okay - I have 100 pages, now I have to build 100 ajax versions and 100 non ajax versions. I was thinking overkill. Not the case. Thanks for the input
  5. ajax.open('get', dept_results_ajax.php?did=' + encodeURIComponent(did))); My question is actually a simple one. To create an ajax driven web application are two similar php files necessary? ie dept_results.php (non ajax version) and dept_results_ajax.php (ajax version)? Can there be one file that can also be the fallback? I may be getting ahead of myself, as I am only on chapter 3. I am just trying to see how others have built their ajax web applications. Thanks, Mark
  6. That threw me off too, I have no idea what the text is referring too. So they are no longer present, what exactly is no longer present? Whats reset? I did figure the same thing, in that learning by doing would get my head around it hopefully in the near future. As I do get hyperfocused into these things. As for now I'll just do what the book says and add e.preventDefault () and e.returnValue = false
  7. function handleForm() { // Do whatever. if (errors) { return false; } else { return true; } } The text goes on to say "Conversely returning anything other than false allows the default event behavior to occur (in that case, the forms submission). The problem with returning false to prevent the default browser behavior is that it only works reliably when the event listener was registered using the traditional approach. For example say event.js added the form submissison event handler using the newer approach. U.addEvent(U.$('theForm'), 'submit', setHandlers); With that code, you would see that the form's submission would go through meaning that the form itself would be reset (upon resubmission) and the event listeners would not be present (they would have been created, but reset upon submission)." It's not clear to me why the U.addEvent custom method wouldn't work here. When we defined the U object on page 276, the addEvent method already had a fall back for browsers that didn't support the addEventListener() method, as below: addEvent: function(obj, type, fn) { 'use strict'; if (obj && obj.addEventListener) { obj.addEventListener(type, fn, false); } else { obj.attachEvent('on' + type, fn); } } Clearly, in the code above that attachEvent() method is used as an alternative for browsers that don't support the addEventListener() method. Question now is why do need to use the e.preventDefault() method on top of everything? Thanks, Mark
  8. Again, another simple question but this one is regarding the example in the book as follows: function someEventHandler(e) { // use e. } The text says "Often the argument is abbreviated as just e or evt, short for event." Are "e" and "evt" reserved keywords? Or is the text just saying that "e" and "evt" are used commonly as the argument? Any argument could have been used such as "x" and "y", correct?
  9. I just took a look at Hartley's attached diagram. wow, I would have expected more native objects. Sure there are arrays, but this nice visual makes things much clearer. Thanks for that.
  10. My apologies for dragging this on with a bland example (I'm still learning this whole deal about objects), but in this simple example dog has 3 properties - color, weight, and name. And then it has one method which is bark. var color = 'brown'; var weight = 50; var name = 'fido'; var dog = { color: color, weight: weight, name: name, bark: function() { var bark = 'woof!'; if(name == 'fido') { return 'bark'; } else { return 'meow'; } } }; alert(dog.color); alert(dog.weight); alert(dog.name); alert(dog.bark()); A comparison would be all the built in methods that javascript already comes with such as toLowerCase(); It's a method. var greeting = 'HELLO WORLD'; alert(greeting.toLowerCase());
  11. Did you get this to work, it seems your post is more of a solution than a question? I also ran across this and noticed numbers was not a parameter of the function and wondered where it came from. Let me know if you still have any issues with it though.
  12. var U = { $: function(id) { 'use strict'; if(typeof id = 'string') { return document.getElementById(id); } // end of typeof } // end of $() function } // end U object This is a rather simple question. The text says the $() function is a property of U, isn't this function technically a method and not a property? Thanks, Mark
×
×
  • Create New...