Jump to content


  • Content Count

  • Joined

  • Last visited

Posts posted by skaterdav85

  1. I wonder bigdave, if you wrote the collection statement like this, would you only get an array of innerHTML values?
    var collection = $('#divContainer .eachDiv').html();


    Doing that only returns the innerHTML of the first items in the collection.Looks like my best bet is to just duplicate data. I didn't want to do this because now the server has to iterate over the data twice, once to create the JS array, and another time to place the data within the DOM.
  2. I have a container div #divContainer that holds 1073 other div's with a class of .eachDiv. I have a text input #search-input where i search through each .eachDiv within #divContainer on the keyup event. The problem is that it seems a little laggy when I type, and I am not sure how to fix this. I realize it is iterating over a lot of items for each keyup which causes the slowness, and I was wondering if anyone had suggestions on how to improve the performance or my approach. I am using jQuery.

    var collection = $('#divContainer .eachDiv');var search = function ($collection, searchPhrase) {	  $collection.each(function () {	  var divText = this.innerHTML.toLowerCase();		  this.style.display = 'block';		 if (divText.indexOf(searchPhrase.toLowerCase()) === -1) {			 this.style.display = 'none';		 }	});};$('#search-input').bind('keyup', function () {	var searchPhrase = this.value;	search(collection, searchPhrase);});

    EDIT: i noticed that it isn't as slow in Chrome. It's not horrible in FF, but it is noticeable. Does Chrome have a faster JS engine?

  3. Can someone help decipher this function?

    function createBoundWrapper(obj, fn) {   return function () {	  return fn.apply(obj, Array.prototype.slice.call(arguments));   }}

    I think I understand most of it. createBoundWrapper returns a function that, when executed, calls fn with obj as the supplied context for this and it passes an array as data. What I don't quite get is why it says Array.prototype.slice.call(arguments)Why not just Array.slice.call(arguments)?My guess is that I don't fully understand the prototype object. All I really know about it is that it is used to add methods and properties to all existing and future instances of an object.

  4. I created a fan site for a band i like using several web services. I found other fan sites that publish news frequently and they have RSS feeds. Is it legal to ###### in the contents of RSS feeds from other sites using cURL or file_get_contents() and display them on my own, which is essentially what i do with the web services except these are RSS feeds? Basically my site would be an RSS reader of these other fan sites but with some extra stuff of my own. Or do i need to ask for permission to read these RSS feeds?

  5. you can also read the values of style properties but only for inline styles of elements. I'm not sure how you would read the computed style of an element, such as the color of an element, if it was applied in an external stylesheet or style block somewhere on your page.jQuery actually will read the computed styles of an element that is wrapped in the jQuery object using the .css() method and passing it no arguments. No idea how it does this though.

  6. ya there doesn't seem to be a clear hierarchy. I was just aware that document is a property of window and both are global. I wasn't sure how navigator fit in, but based on my test, i think navigator is 'on the same level' as window, rather than being a property of window.

  7. That seems a little messy too, since I don't know how the function operates outside of the jQuery object. I guess when developers really need to use animated UI effects, they use libraries or end up writing their own. I was hoping there was a lightweight package of animation functions that could be used to implement into a custom library, similar to how Sizzle is available for implementing DOM element retrieval using CSS selectors in JS.

  8. Are there any JS animation objects / functions available out there than can be used to incorporate into a custom library? I've created an app that uses raw JS, but it would be nice if I could have a few functions available to perform some slight animation effects like fading in. I know I could use another library like jQuery, but it it seems overkill to load the entire library for one transition effect.

  9. Actually, some (most) browsers support it natively. For IE6 and IE7 it would have to parse the selector and figure out which elements it needs to look through to find the matches.
    If some browsers support it natively, how would you use that to say, fetch all <li> elements within a <ul> with an id of "nav"?
    I'm not sure how the parsing works, but it is probably quite complex. Actually, jQuery implements another library called SizzleJS. You could delve into the source code here.
    I did not know this. Sizzle looks like a great way to implement selectors if you wanted to build your own library.The reason I ask this is because I was developing an app at work using raw JS as I wanted to improve my raw JS skills and be less dependent on a library, but as I was doing this, I found it hard to target a specific set of elements since I was only aware of the standard techniques. Looks like I could have used Sizzle for this. =) Has anyone used Sizzle alone in a project?
  10. I was wondering, how does a JS library like jQuery implement selectors, from a general point of view? The only thing I can think of is that it parses the selector such as 'div#nav ul li' and then behind the scenes it uses getElementById(), getElementsByTagName(), childNodes, and parentNode to filter through an initial, larger collection and return a smaller, filtered collection based on the selector you typed. Or is there some other magic going on that I don't know about?

  11. I have a friend who wants to start a Groupon-like site, where you have daily deals for a particular subject. Apparently there are several packages you can buy which provide the typical daily-deal site functionality. I looked at a few online but I am not sure which one is best. He is also concerned with customizing the design/theme, which I said I would do. Anyone have any recommendations?

  12. You know how you can jump down/up to a particular part of the page if you put the element's id in the url? So by putting the id in the href attribute of an anchor, you can cause the page to jump to that id.

    <div id="div1">this is my div</div><a href="#div1">somewhere on the page</a>

    Is there a way to control this behavior in JavaScript? I have points on a map and each point knows which ID to jump to, but I don't know how to tell it to jump to a particular ID on the page when clicked. I have already added a click event listener to each point. I just need to make it do the jumping part.

  13. so i finally got the site to work on iOS. The meta viewport tag was working. I think I just had to clear my cache. Anyways, now it is zoomed in too much on the Android Browser, but only on some devices I think. I tried it on my friend's phone and he has Android 2.1 and it shows up ok, but it shows up zoomed in too much on the emulator using 2.1 and my phone which is 1.5. Any idea of why the inconsistencies? My meta-viewport tag is:

    <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width" />

    My link is: http://itphosting1.com/dtang/jarritos/Thanks!

  • Create New...