More on the JavaScript bug I had - and how it relates to Spry

This post is more than 2 years old.

So, a few hours ago I posted about an odd JavaScript issue I was having where I couldn't set a field's disabled property. Turns out it was an issue with Spry, and one that makes sense if you think of it. My code was doing something like so:

if(offset == 0) $("prevbutton").disabled=true; else $("prevbutton").disabled=false;

if((offset + pageSize) >= numRows) $("nextbutton").disabled=true; else $("nextbutton").disabled=false;


This code was run anytime you would click the Previous or Next buttons. It was a basic page handler for my dataset. The updateRegion call basically redrew the region. I had code inside it to check and see if a row should be displayed:

<tr spry:repeat="dsIssues" spry:even="adminList0" spry:odd="adminList1" spry:test="{ds_RowNumber} >= pageOffset && {ds_RowNumber} < pageStop">

The problem came up due to the fact that I had this inside the region:

<input type="button" id="prevbutton" value="Prev" onclick="UpdatePage(pageOffset - pageSize);" disabled="true">

I had the previous button disabled at first since, obviously, you start on the first page. However, when I ran the updateRegion command, Spry essentially "reloaded" my initial HTML, which means the disabled=true was also being rerun.

Obvious. But of course - most bugs are (after you fix them).

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA