[jQuery] Re: How can I either clone just one class and children or append better html code

2008-05-27 Thread Wizzud

Not entirely clear what is required to be cloned - the code you have
shouldn't really be cloned 'as is' because it has ids in it, which
would require a fair amount of manipulation to make it valid.
If you simply want to format it into a more readable/maintainable form
then, as an example...

var code = [
  'div id=block'
,   'h1BITE ME! /h1'
,   'div class=eplist'
, 'table'
,'th'// should this be a tr?
,  'tdTitle/td'
,  'tdEpisodenumber/td'

// ... etc, etc ...

, 'h2Remove ep from list/h2'
,   '/a'
, '/div'
].join('');

But, yes you can clone just one instance of a class, eg ...
$('.class:first').clone()

On May 27, 10:06 pm, tripdragon [EMAIL PROTECTED] wrote:
  have this code that works! But looks like butt. As well as that this
 is a recipe for hell every-time I need to update it.
 I had clone working on the generated html code from the Rails server
 code. But in my simple tests the clone was cloning the class or id and
 it then more just make clones of the clones. Woot. So it became a
 power of 2 which as you know. ...

 From my short reading I cannot find any tools to fix jquery to paste
 code cleaner due to javascript restriction spacing..

 script type=text/javascript
 $(document).ready(function(){

   $('#addmore').click(function() {
 $('#block').append('div id=blockh1BITE ME! /h1 div
 class=eplisttable th tdTitle/td tdEpisodenumber/td
 tdStatus/td tdWatched/td tdHave/td tdNext/td
 tdPublished/td /thtr td input
 id=episode_episode_attributes__title
 name=episode[episode_attributes][][title] size=30 type=text / /
 td td input id=episode_episode_attributes__episodenumber
 name=episode[episode_attributes][][episodenumber] size=30
 type=text / /td td select
 id=episode_episode_attributes__status
 name=episode[episode_attributes][][status]option
 value=1Watching it/option option value=2Saw it/option/
 select /td td input id=episode_episode_attributes__watched
 name=episode[episode_attributes][][watched] type=checkbox
 value=1 /input name=episode[episode_attributes][][watched]
 type=hidden value=0 / /td td input
 id=episode_episode_attributes__have name=episode[episode_attributes]
 [][have] type=checkbox value=1 /input
 name=episode[episode_attributes][][have] type=hidden value=0 /
 /td td input id=episode_episode_attributes__next
 name=episode[episode_attributes][][next] type=checkbox value=1 /input 
 name=episode[episode_attributes][][next] type=hidden

 value=0 / /td td input
 id=episode_episode_attributes__published
 name=episode[episode_attributes][][published] type=checkbox
 value=1 /input name=episode[episode_attributes][][published]
 type=hidden value=0 / /td/tr/table h2Notes/h2 p
 textarea cols=100 id=episode_episode_attributes__notes
 name=episode[episode_attributes][][notes] rows=2/textarea /
 pa href=# class=pukh2Remove ep from list/h2/a/div');
   });

 $('.puk h2')
 .livequery('click', function(event) {
 $(this).parents('.eplist').remove();
 return false;
 });

 });

 /script


[jQuery] Re: How can I either clone just one class and children or append better html code

2008-05-27 Thread tripdragon

sweet the :first did the trick. constantly reformatting the code drove
me bonkers



On May 27, 7:42 pm, Wizzud [EMAIL PROTECTED] wrote:
 Not entirely clear what is required to be cloned - the code you have
 shouldn't really be cloned 'as is' because it has ids in it, which
 would require a fair amount of manipulation to make it valid.
 If you simply want to format it into a more readable/maintainable form
 then, as an example...

 var code = [
   'div id=block'
 ,   'h1BITE ME! /h1'
 ,   'div class=eplist'
 ,     'table'
 ,        'th'    // should this be a tr?
 ,          'tdTitle/td'
 ,          'tdEpisodenumber/td'

 // ... etc, etc ...

 ,     'h2Remove ep from list/h2'
 ,   '/a'
 , '/div'
 ].join('');

 But, yes you can clone just one instance of a class, eg ...
 $('.class:first').clone()

 On May 27, 10:06 pm, tripdragon [EMAIL PROTECTED] wrote:

   have this code that works! But looks like butt. As well as that this
  is a recipe for hell every-time I need to update it.
  I had clone working on the generated html code from the Rails server
  code. But in my simple tests the clone was cloning the class or id and
  it then more just make clones of the clones. Woot. So it became a
  power of 2 which as you know. ...

  From my short reading I cannot find any tools to fix jquery to paste
  code cleaner due to javascript restriction spacing..

  script type=text/javascript
  $(document).ready(function(){

    $('#addmore').click(function() {
  $('#block').append('div id=blockh1BITE ME! /h1 div
  class=eplisttable th tdTitle/td tdEpisodenumber/td
  tdStatus/td tdWatched/td tdHave/td tdNext/td
  tdPublished/td /thtr td input
  id=episode_episode_attributes__title
  name=episode[episode_attributes][][title] size=30 type=text / /
  td td input id=episode_episode_attributes__episodenumber
  name=episode[episode_attributes][][episodenumber] size=30
  type=text / /td td select
  id=episode_episode_attributes__status
  name=episode[episode_attributes][][status]option
  value=1Watching it/option option value=2Saw it/option/
  select /td td input id=episode_episode_attributes__watched
  name=episode[episode_attributes][][watched] type=checkbox
  value=1 /input name=episode[episode_attributes][][watched]
  type=hidden value=0 / /td td input
  id=episode_episode_attributes__have name=episode[episode_attributes]
  [][have] type=checkbox value=1 /input
  name=episode[episode_attributes][][have] type=hidden value=0 /
  /td td input id=episode_episode_attributes__next
  name=episode[episode_attributes][][next] type=checkbox value=1 
  /input name=episode[episode_attributes][][next] type=hidden

  value=0 / /td td input
  id=episode_episode_attributes__published
  name=episode[episode_attributes][][published] type=checkbox
  value=1 /input name=episode[episode_attributes][][published]
  type=hidden value=0 / /td/tr/table h2Notes/h2 p
  textarea cols=100 id=episode_episode_attributes__notes
  name=episode[episode_attributes][][notes] rows=2/textarea /
  pa href=# class=pukh2Remove ep from list/h2/a/div');
    });

  $('.puk h2')
      .livequery('click', function(event) {
          $(this).parents('.eplist').remove();
          return false;
      });

  });

  /script