سؤال

Am using Struts2 Jquery plugin,Please take a look on this code.

<s:iterator status="stat" value="primeDisplayLocationBeans">
    <tr>
        <td class="last center">        
            <sj:a openDialog="myremotedialog" href="opendemographicdetails?locationId=%{id}">
                Demographic
            </sj:a>
            <sj:dialog id="myremotedialog"   autoOpen="false" 
                    title="Demographic Details" width="800"/>
        </td>
    </tr>
</s:iterator>

Now what happening the code create a list of dynamic link,and if i click those link it will open the respective content on remote dialog.But the problem is the first row link is not working,but all the other link are working properly and opening there respective dialog.For the first link not even the dialog is opening. The error its showing in Java script Console is:

Cannot set property 'href' of undefined

هل كانت مفيدة؟

المحلول

You are assigning the same ID to multiple elements, that is against (X)HTML specs, and doesn't allow you to refer uniquely to an element later (having multiple of them with the same ID).

Parametrize your ID with something like this:

<s:iterator status="stat" value="primeDisplayLocationBeans">
   <tr>
      <td class="last center">
         <sj:a openDialog="myremotedialog_%{#stat.index}" 
               href="opendemographicdetails?locationId=%{id}">Demographic</sj:a>

         <sj:dialog id="myremotedialog_%{#stat.index}" 
                    autoOpen="false" title="Demographic Details" width="800"/>


      </td>
   </tr>
</s:iterator>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top