O grupo no qual você está postando é um grupo da Usenet. As mensagens postadas neste grupo farão com que o seu e-mail fique visível para qualquer pessoa na internet.
I'm generating some tables for data input and I'd like to perform one calculation automatically, so I'd connect all inputs from one column to an onchange event (using MochiKit.Signal, of course).
If I have something like 1000 rows on this table, would having 1000 "connect"s be too much? Is there a better way to make this automatic? (I'd like to avoid having to press a button to perform the calculation, but if there's no way this is what I'll implement...)
This will be running mainly on Firefox (Linux and Windows) and Internet Explorer (Windows). Machines are reasonably fine and running Windows XP (there's one with an updated version of IE running Windows 98, but only because of other software, I believe it would run XP just fine.).
> I'm generating some tables for data input and I'd like to perform one > calculation automatically, so I'd connect all inputs from one > column to an > onchange event (using MochiKit.Signal, of course).
> If I have something like 1000 rows on this table, would having 1000 > "connect"s > be too much? Is there a better way to make this automatic? (I'd > like to > avoid having to press a button to perform the calculation, but if > there's no > way this is what I'll implement...)
> This will be running mainly on Firefox (Linux and Windows) and > Internet > Explorer (Windows). Machines are reasonably fine and running > Windows XP > (there's one with an updated version of IE running Windows 98, but > only > because of other software, I believe it would run XP just fine.).
You should probably be fine. That said, test it with say 5,000 rows and see what happens, especially in IE. Firefox is not immune though, you should test it thoroughly too. If this breaks somehow, please open a new Trac ticket and attach your test case.
Beau Hartshorne <hartsho...@gmail.com> writes: > You should probably be fine. That said, test it with say 5,000 rows and see > what happens, especially in IE. Firefox is not immune though, you should test > it thoroughly too. If this breaks somehow, please open a new Trac ticket and > attach your test case.
I've just spoken to the client and we have found our "worst case scenario" here, on an old machine running Win98 + IE 6 (the slower we have here). I'll write a test table and see how it performs there.
It will probably be too slow. I've found that once the number of "connect"s on a page exceeds about 500, you get the dreaded "a script on this page is running slowly" error before the browser finishes evaluating all the connect's. Just my experience, I'd be interested in yours. Another option would be to set a function on a timer that would automatically recalculate by pulling the values of the fields you're interested in on a periodic basis. This wouldn't have _quite_ the same behavior, but would be pretty close, and would likely be a lot faster to render the page.
"Peter Mularien" <pmular...@gmail.com> writes: > It will probably be too slow. I've found that once the number of > "connect"s on a page exceeds about 500, you get the dreaded "a script > on this page is running slowly" error before the browser finishes > evaluating all the connect's. Just my experience, I'd be interested in > yours. Another option would be to set a function on a timer that would > automatically recalculate by pulling the values of the fields you're > interested in on a periodic basis. This wouldn't have _quite_ the same > behavior, but would be pretty close, and would likely be a lot faster > to render the page.
Hmmm... But it might cause some unexpected surprises such as values appearing when the user is doing something else or putting too much load on the browser. On the other hand, it would make one thing easier to implement in the future (but I'm not worried with that now and I don't even know if I'll implement this new feature).
Since I'm also generating the table dinamically, I'm doing the process in two steps:
- creating the tables & using swapDOM to put them on screen (loops through the data)
- looping again and connecting signals to the calculation function (I can't use the same loop because there's no element to connect to...)
This was my first approach, just to see if it would work for the client -- and it does -- but I'm willing to make it robust and "correct".
I'll be doing the tests next Wednesday (I might be asking for the client to test it before, but you know that his description is never like our "feeling" of it...) and I'll post here the results.
For too many fields where filling them is a slow process it would be great to be able to detect what has changed and do the operation just on it instead of recalculating everything all the time (imagine how many useless calculations would be done until the user fills 100 -- very very trivial to have that here, common case would be something like 300... -- cells with values like "0,53", "0,542", etc.).
I would really prefer having something that is dinamically connected to each cell that needs to be recalculated.
"Peter Mularien" <pmular...@gmail.com> writes: > It will probably be too slow. I've found that once the number of > "connect"s on a page exceeds about 500, you get the dreaded "a script > on this page is running slowly" error before the browser finishes > evaluating all the connect's. Just my experience, I'd be interested in > yours. Another option would be to set a function on a timer that would > automatically recalculate by pulling the values of the fields you're > interested in on a periodic basis. This wouldn't have _quite_ the same > behavior, but would be pretty close, and would likely be a lot faster > to render the page.
Hi!
I finally got back to this project and you're correct. I get a window asking if I want to continue or to interrupt the script that is running. I'll think more about this... Maybe if I mount the table piece by piece, putting blocks of 100 rows each time this gets more manageable.
Beau Hartshorne <hartsho...@gmail.com> writes: > You should probably be fine. That said, test it with say 5,000 rows and see > what happens, especially in IE. Firefox is not immune though, you should test > it thoroughly too. If this breaks somehow, please open a new Trac ticket and > attach your test case.
There was no bug, but it wasn't fast enough to be completed without Firefox complaining about how long the script was taking to finish.
The main code for my test is:
for (var index; index < 400; index++) { var sample = index; log ('Sample:', sample); var elements = [sample, INPUT({'name':sample+':sample', 'id':sample+':sample'}, null), LABEL({'name':sample+':result', 'id':sample+':result'}), [INPUT({'name':sample+':ignore_sample', 'id':sample+':ignore_sample', 'value': true, 'type': 'checkbox'}, null), LABEL(null, 'Ignore Reading'),], ]; extend(lines, new Array(elements)); }
and later, in another function (after swapDOM...):
for (var index; index < 400; index++) { var sample = index+':sample'; connect(sample, 'onchange', calculate_results); }
Any hints on how to make it better would be appreciated.
>> You should probably be fine. That said, test it with say 5,000 >> rows and see >> what happens, especially in IE. Firefox is not immune though, you >> should test >> it thoroughly too. If this breaks somehow, please open a new Trac >> ticket and >> attach your test case.
> There was no bug, but it wasn't fast enough to be completed without > Firefox > complaining about how long the script was taking to finish.
> The main code for my test is:
> for (var index; index < 400; index++) { > var sample = index; > log ('Sample:', sample); > var elements = [sample, > INPUT({'name':sample+':sample', > 'id':sample+':sample'}, null), > LABEL({'name':sample+':result', > 'id':sample+':result'}), > [INPUT({'name':sample+':ignore_sample', > 'id':sample+':ignore_sample', > 'value': true, > 'type': 'checkbox'}, null), > LABEL(null, 'Ignore Reading'),], > ]; > extend(lines, new Array(elements)); > }
You should really never, ever, call "new Array". It's silly. In this case the array you created is new anyway.. why?
Also, index isn't initialized to 0.. so the first run through is going to be undefined... that can't be correct as written here.
> and later, in another function (after swapDOM...):
> for (var index; index < 400; index++) { > var sample = index+':sample'; > connect(sample, 'onchange', calculate_results); > }
> Any hints on how to make it better would be appreciated.
A full example that people could play with would help.
Bob Ippolito <b...@redivi.com> writes: > You should really never, ever, call "new Array". It's silly. In this case the > array you created is new anyway.. why?
I dunno. I've seen lots of codes using "new Array" and this is why I used it. ;-)
> Also, index isn't initialized to 0.. so the first run through is going to be > undefined... that can't be correct as written here.
It was the test code. Real code comes with a value from the database.
> A full example that people could play with would help.
Here it is. You'll just have to fix the path to the packed version of MochiKit. This is just multiplying each numeric value by 3.
I've just made a few simplifications from my real case (where my for loop iterates of a JSON result containing data that will be turned into table rows instead of generating a loop with "known" indexes), but kept the structure of everything else.
Thanks for your attention, -- Jorge Godoy <jgo...@gmail.com>
> Here it is. You'll just have to fix the path to the packed version of > MochiKit. This is just multiplying each numeric value by 3.
> I've just made a few simplifications from my real case (where my > for loop > iterates of a JSON result containing data that will be turned into > table rows > instead of generating a loop with "known" indexes), but kept the > structure of > everything else.
I don't think you can attach anything to list posts. Could you please submit a trac ticket with an attachment?
Beau Hartshorne <hartsho...@gmail.com> writes: > I don't think you can attach anything to list posts. Could you please submit a > trac ticket with an attachment?
The limit that won't make the window appear seems to be 308. So, something like 615 (616 to be exact) loops in that construction is the limit for a standar Firefox installation.
> Here it is. You'll just have to fix the path to the packed version of > MochiKit. This is just multiplying each numeric value by 3.
> I've just made a few simplifications from my real case (where my > for loop > iterates of a JSON result containing data that will be turned into > table rows > instead of generating a loop with "known" indexes), but kept the > structure of > everything else.
> Could you take a look at it? Is my code wrong? Should I adopt a > different > approach to the problem? :-)
> I'm really willing to go on with this part of the code (even though > I'm > working on different parts simultaneously, this is pending on my > side...).
Hi Jorge,
If you used native browser events to connect to a lot of elements, your page would probably slow to a crawl as well. I don't think your code or Signal are introducing any other problems on top of this one.
A solution to your problem might be to connect() at a higher level for an event, say on document or window. From there, you can see where it came from (http://mochikit.com/doc/html/MochiKit/ Signal.html#fn-target). Something like this *should* work in your situation, but you'll need to write and test the code to be sure.