@mkmanning
An even more important performance gain can be had by
not doing string concatenation (I put a caveat about this in the code
comment's also), but build an array of your html and then join the
array; it's siginficantly faster.
Funny that you mention this. In current browser
Hi Michael,
It is working fine. Thank You Very Much.
Just one final question. This is part of a form.
When the form is submitted but not validated on the server I rebuild
the themes list.
There is only one problem: when I delete a theme all disappear.
I think it is because themes is being
You could post to the server with ajax, or since you have all the data
server-side, just render the page with the themes array already
populated and call the build function
On Feb 25, 11:55 am, shapper mdmo...@gmail.com wrote:
Hi Michael,
It is working fine. Thank You Very Much.
Just one
I am not using Ajax because I need to submit the form all at once.
I cannot submit the themes because the user is not created yet.
Anyway, the other option you suggested me was what I was trying:
$test = $('#Test');
$test.append(themes);
Where Test would be an hidden input.
I
Hi,
I think I did that ...
I have this example working with Subjects and FriendlyLevels function
to add the e correctly:
http://www.27lamps.com/Beta/List/List4.html
Then I tried to do the same but for levels:
http://www.27lamps.com/Beta/List/List5.html
But I keep having errors.
What am I
Hi Miguel, not sure if it will solve your problem, but I find it is
much faster to create a complete html string and then append it
instead of doing lots of appends, which are slow.
//this handles the li content
var li =
Creating a complete html string won't solve the current problem; it is
faster, and usually the way I prefer doing it also (see my note
further below though), but as I indicated in a code comment, since
this appears to be based on user input, the list (hopefully) won't be
very big, so the speed
@Michael,
I just installed Firebug and I almost made this working.
The only problem I have is when I am adding the levels to the list as
html and as hidden input:
+friendlyLevels(t[1].text.join(', '))+'br /'
$('input').attr({'type':'hidden','name':'Themes['+i
The problem is t[1] is now an array of objects, so you have to access
the text and value attributes of the objects by their array index.
Here are the buildThemesList function and the friendlyLevels functions
rewritten to account for that.
function buildThemesList(){
Hello,
I tried to make the change:
levels.each(function(){
levelsCsv.push({'text':this.value,'value':$(this).next().text()})
})
But I get an error on Firebug:
levels.each is not a function
Am I doing something wrong?
I also made a change on
P.S: I updated my example as usually:
http://www.27lamps.com/Beta/List/List3.html
On Feb 20, 5:02 pm, mkmanning michaell...@gmail.com wrote:
levels.text = $('input[name=Levels]:checked + label');
levels.value = $('input[name=Levels]:checked');
Those don't get you the right values for
That's because you changed levels to an object, which you don't need
to. Just use the original var levels = $('input:checkbox:checked'),
and then
levels.each(function(){
levelsCsv.push({'text':this.value,'value':$
(this).next().text()})
})
On Feb 23, 9:37 am,
Hi,
I followed your tips but I still have a few problems.
The subject is working fine but when I do the same to the levels it
does not work.
I think the problem, but I am not sure, is in:
levels.each(function(){
levelCsv.push(this.value);//array to hold the levels
});
I changed
levels.text = $('input[name=Levels]:checked + label');
levels.value = $('input[name=Levels]:checked');
Those don't get you the right values for the levels object, they both
return a jQuery object.
Accessing the levels object as this.value won't work either.
Try this:
levels.each(function(){
Hi Michaell,
Sorry for the delay but when I started using JQuery 1.3 I solved this
problem but I got a few others on my application.
Anyway, there is just something else that I am not able to solve.
When I add a theme I need to:
1. For the Select (Subject), add the selected value to hidden
You could modify the subject variable being put into the array to make
it an object: subject = {}
then add the option's value and text to it:
subject.value = $('#Subject option:selected').val();
subject.text = $('#Subject option:selected').text();
or in one line to replace what's there now:
Hi,
I was trying to integrate your code on my web application and the
following happens:
I am able to add a theme. But when I try to add a second theme I get
the following error:
[Exception... 'type property can't be changed' when calling method:
[nsIDOMEventListener::handleEvent] nsresult:
Scripts block other assets from downloading, so the most appropriate
place for them (most of the time), is at the close of the body. This
allows your page to render, and then allows you to add behavior as
progressive enhancement. It's generally good practice; Google
progressive
Hi,
I would like to include the script on the head of the document and
using an external JS file.
So I inserted it inside the Document.Ready function. I upload a new
example showing the problem I have:
http://www.27lamps.com/Beta/List/List2.html
In this example I didn't use the external JS
Yes,
I tried that to but the problem persists. I updated the new version:
http://www.27lamps.com/Beta/List/List2.html
I am able to add 1 theme to the list ...
Then all the other themes I add are not added to the list ...
But I think they are being added to the themes array.
The index also
if you're using the ready function, remove the inner (function($)
{ ... })(jQuery); wrapper
On Feb 18, 9:13 am, shapper mdmo...@gmail.com wrote:
Hi,
I would like to include the script on the head of the document and
using an external JS file.
So I inserted it inside the Document.Ready
The problem is with the version of jQuery you're using. Update to 1.3
(and don't include a space in the URI).
Try your code with the Google js api and it will work (I just did,
even with the duplicate jQuery wrapper functions).
On Feb 18, 9:28 am, shapper mdmo...@gmail.com wrote:
Yes,
I
I have been trying to make this work but no success ...
... in fact the inputs get undefined.
I am not sure if I am using your function on the right way.
The function should be called, I think, after adding or removing an
item to reorder the ids.
Anyway, I created an example:
I added an input which shows the number of items in the list ...
The problem is that I am not able to reorder the list so it is 0
based ...
Any idea?
Thanks,
Miguel
On Feb 18, 1:48 am, shapper mdmo...@gmail.com wrote:
I have been trying to make this work but no success ...
... in fact the
That's because you have that empty li style=display:none/li. Is
it really necessary?
just decrement the index to start at 0:
$('#Themes li').each(function(index){
index--;
$('input:hidden', this).each(function(){
var fixName = $(this).attr('name').replace(/\[\d\]/, '['+index
+']');
Here's a wholly different approach for consideration. Rather than try
and keep track of LI elements and regex their names with the current
index, just use an array placeholder and rebuild the list. Chances are
if the user is required to add items, the list isn't going to get
unmanageably huge (at
You could remove the entire list everytime and regenerate it from
javascript. Is Themes[0].Subject the actual name, or are you trying
to refer to a javascript object in an array with the attribute
'Subject' which contains the name you are looking for? If it is the
latter, this won't work.
Themes[0].Subject is the actual name ... It is so to be read by an MVS
framework into a List.
Basically when the page loads some items are already there rendered on
the server.
They are always with the correct order.
However, when I add / remove items to that list the order might
change ...
So
At the risk of repeating myself from other posts, You might save
yourself future problems if you use standards-based id/name attributes
(and if the framework you're using doesn't allow that, seriously
consider a different framework):
HTML 4 spec section 6.2 says, ID and NAME tokens must begin
Yes. The W3C validator has...issues.It's been broken and out of step
with specs many times; it's a valid tool but don't take it's word as
gospel. User-agents are written to follow the specs (occasionally), or
their authors ideas of what should be done, but they aren't written to
follow what the
I think your naming should be fine.because i sometimes use these kind of
naming to populate my list on the server side, I use Struts 2.
I ran into a problem similar to yours recently while doing an Ajax example
for my friend.
What i did was just like seasoup suggested.
you might want to try
Probably not the most efficient function, but should work:
$('#ThemesList li').each(function(index){
$('input:hidden', this).each(function(){
var fixName = $(this).attr('name').replace(/\[\d\]/, '['+index
+']');
$(this).attr('name', fixName);
});
});
- ricardo
On Feb 11,
32 matches
Mail list logo