Bug Tracker

Modify

Ticket #3453 (closed enhancement: invalid)

Opened 5 years ago

Last modified 4 years ago

append() etc functions to accept many arguments

Reported by: antix Owned by: flesler
Priority: major Milestone: 1.3
Component: core Version: 1.2.6
Keywords: multiple arguments, append, prepend, before, after Cc:
Blocking: Blocked by:

Description

for example

var $container = $("<div />"); var $input = $("<input />"); var $okButton = $("<button>Ok</button>"); var $CancelButton = $("<button>Cancel</button>");

$container.append($input, $okButton, $cancelButton);

This way you have references to the content to add events etc and only one call to append()

It would also apply to prepend(), before() and after()

to maintain the ability to change these functions in the future you could let it accept an array

for example $container.append([$input, $okButton, $cancelButton]);

Change History

comment:1 Changed 5 years ago by flesler

  • need changed from Review to Patch
  • Status changed from new to assigned
  • Component changed from unfilled to core

comment:2 Changed 5 years ago by dmethvin

I'm not clear on what the enhancement is here; you can already pass multiple arguments to append, prepend, etc. by virtue of the code in jQuery.clean that checks for array-like arguments. This has worked for a long time:

$(function(){
   var a = $("<div>hello</div>");
   var b = $("<div>there</div>");
   var c = $("<div>guys</div>");
   $("#test").append(a,b,c);
});

comment:3 Changed 4 years ago by dmethvin

  • Status changed from assigned to closed
  • Resolution set to invalid

Since this already works as desired I'll close the ticket.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.