Jump to content

goodacre.liam

Members
  • Posts

    21
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

goodacre.liam's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. You probably want something like: // Renders a single item as html var renderItem = function (item) { return '<img src="' + encodeURI(item) + '">' } // Render and display all the photo file items $('#photosTab').html($.map(json.photoFiles, renderItem)) Before you get unnecessarily far down the rabbit hole with manual dom interaction, take a look into Facebook's React library. It allows you to program much more intuitively, and simply by saying that your 'view' is a function of the state of your application at any point in time. Hope this helps.
  2. I'm not experienced with it (in fact I had never heard of either of the two). You'll either have to write a plugin for it (if that functionality can be added by plugin), or modify the bsmSelect source for your needs. Might be worth a Google for plugins that other people have written for it, to get a picture of what can be accomplished.
  3. Awesome! I'm glad to have helped.
  4. It is definitely possible: There is a fork of asmSelect called bsmSelect https://github.com/vicb/bsmSelect Check out the bottom example on this page: http://www.suumit.com/projects/bsmSelect/examples/index.html Is this similar to what you wanted? As bsmSelect also allows plugins: so you should be able to add in functionality that allows two drop-down selection boxes with a parent-child relationship. Hope this helps.
  5. Unless you have further issues to discuss, please mark this problem as 'Solved'.
  6. I was referring to this part of the code you posted: if( (p1cards.length = 0)||(p2cards.length = 0) ){
  7. To set the id of an element, you can use the 'attr' method: // setter $('...selector...').attr('id', 'thenewid'); // getter var id = $('...selector...').attr('id'); I would say that it would be better to use add/remove class as smoseley suggested. Although I don't fully know your situation, ids may be applicable. @smoseley: You missed out the function keyword from the second procedure. $(".featured").hover(function () { $(this).addClass('hover'); }, function () { $(this).removeClass('hover'); });
  8. Also, in your first if statement you are using '=' which is the assignment operator. You should be using '===' for the equality comparison operator. To extend on what 'requinix' said: the 'click' method on a jQuery object attaches an event handler to when the related dom elements are clicked. It doesn't invoke a click. To invoke, I believe there is a method called 'trigger': $('...').trigger('click'). I think you need to rethink your program design - does this really require any recursion? Regards, Liam Goodacre
  9. My interpretations: A. You are wanting to use an html file as a template for inserting data into and then attaching into your current web page. B. You are wanting to read an html file and extract data from it. For A, have a look at JavaScript templating libraries such as Handlebars.js {http://handlebarsjs.com/} or Moustache.js {https://github.com/janl/mustache.js}. For B, you could create an html entity that isn't attached to the dom. Load the html file via ajax, and use the file contents as the entity's inner-html. Then traverse the entity's children to extract the data required. Regards, Liam Goodacre
  10. This thread is brilliant. Also, I'm sorry mate, I've tried going through your code but it is pretty unfathomable. Although I think you may be wanting to use an object instead of an array: var country = { 'Pakistan' : { 'Punjab' : ['Faisalabad','Lahore','Multan'], 'Sindh' : ['Karachi'] }, 'USA' : { 'New York': ['New York','New York2'] } };
  11. Is it because the majority of your code is actually commented out from the beginning of this line: /*for (x=0;x<8;x++){
  12. Hey, here are a few pointers: The reason your JavaScript doesn't seem to be executing properly is because it is assigning the click handler before the element exists! One way to defer your code from executing until the DOM is ready (meaning that your element will have been loaded), is to use the following code: // Once the DOM is ready jQuery(function ($) { // Add a #button click event callback $('#button').click(function(){ alert('Hello'); }); }); The jQuery function accepts function expressions which it will execute when it detects the DOM has loaded. An alternate way is to shift all your 'script' tags to the bottom of the body, so that the script will always execute after the element is loaded. This would be my preferred method. Another point is that you might want to start using html5 now. This means we can get rid of the nasty doctype and replace it with: <!doctype html> Under this doctype, script tags no-longer need an explicit 'type' if they are JavaScript. The convention is also to never attach JavaScript to elements as inline attributes: <input onfocus="outline();" /> The outline function should be attached using JavaScript, similar to the way you wish to attach a click handler: $('#form1 input:not([type=submit])').focus(outline); One last point is that I think you have your form tag under an illegal parent (I could be wrong). In your case, the form should wrap around the whole table. Hope this helps. Liam Goodacre
  13. From what I understand from your post, you should just need to change: if (error == -1) To the following: if (error !== -1) Hope this helps.
  14. So do you just mean the following? // when clicking on the document $(document).click(function () { // hide element '#div2' $('#div2').hide(); }); Hope this helps.
  15. Instead of onclick on the submit button, attach to the onsubmit event of the form. Also on your buttons, their 'type' should be set to 'submit' not 'button'. If you wish to use jQuery to attach your events, you could do something along the lines of: jQuery(function ($) { $('#validate').submit(function (e) { // validation code... // use 'e.preventDefault()' to stop form submission }); }); Also in your JavaScript you have the following line: if(data = "yes") Shouldn't this be: if (data === "yes") Hope this helps.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.