www.webdeveloper.com
Results 1 to 9 of 9

Thread: Up yes, down no ...

Hybrid View

  1. #1
    Join Date
    Nov 2009
    Posts
    17

    Exclamation Up yes, down no ...

    Hello, I have a problem with my code - I made a function to manage "divs" - moving them up, down or remove them (these divs are in one "container div" and I am using jQuery .each function to rebuild them to an array).... its working really nice, but .... I can move these boxes only up when I click on down arrow, it does nothing... but the script is working well, I tried it by alert and many times checked the code - I am lost ... here is the script:
    Code:
    function move_element(which, where){
      var begin = new Array();
      var end = new Array();".
      var elements = new Array();
      var found = new Array();
      var old_elements = make_array("positions");
      for(i=0;i<old_elements.length;i++){
        if(i < where && i != which){
          begin.push(old_elements[i]);
        }else if(i == which){
          found[0] = old_elements[i];
        }else if(i >= where){
          end.push(old_elements[i]);
        }
      }
      $("#form_inputs_add").html(begin.concat(found,end).join(""));
      refresh_controls();
    }
    make_array() will make an array , refresh_controls just update up, down arrows(delete up for first element and so)....I will be glad for every help .... thank you. If you need more code or so, just ask.

  2. #2
    Join Date
    Oct 2006
    Posts
    939
    It too bad you have to refer with jQuery, cannot do with javascript alone?

  3. #3
    Join Date
    Nov 2009
    Posts
    17
    ... why ? jQuery is more easy and it works same ... I do with jQuery just retriving html
    $("#form_inputs_add .element").each(function(){
    bla bla bla ....
    });
    and then saving it back(edited):
    $("#form_inputs_add").html(elements);
    .... why to dont use it ? this is simpleir - I think problem isnt here ... For "up" arrow it works well and fast - down arrows work, but it DONT change the positions - but the "algorithm" looks well :/ try to look at it too - maybe I just missed a little problem ... I really dont see anything wrong :/

  4. #4
    Join Date
    Nov 2009
    Posts
    17
    lol no help at this forum ?

  5. #5
    Join Date
    Oct 2006
    Posts
    939
    Only unless you abandon jquery.

  6. #6
    Join Date
    Nov 2009
    Posts
    17
    are you asshole ? did you read my post ? tell me what is bad on jQuery ? Why to dont use it, when I use it almost everywhere and it is usefull ... tell me ....

  7. #7
    Join Date
    Jan 2009
    Posts
    3,346
    It seems like you might be trying to recreate existing functionality in jquery. Have you looked at creating a sortable?

    http://docs.jquery.com/UI/Sortable

  8. #8
    Join Date
    Nov 2009
    Posts
    17
    ... no I missed it thx

  9. #9
    Join Date
    Nov 2009
    Posts
    17
    I already did it, thank for good tip

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles