Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

jquery - each / click function not working -


edit: works, not sure why?

  $('button').each(function() {     $(this).bind(         "click",         function() {             alert($(this).val());         });   }); 

i'm not sure why isn't working... right now, i'm trying output alert button value, it's not working on page. don't console errors in firebug , can't see prevent working.

my html looks this:

<table id="addressbooktable"> <thead>     <tr>         <th>name</th>         <th>action</th>     </tr> </thead>  <tbody>     <tr>         <td>7892870</td>         <td><button id="button-20" class="custom-action" value="xy89" name="info">click</button></td>     </tr>      <tr>         <td>9382098</td>         <td><button id="button-21" class="custom-action" value="xy544" name="info">click</button></td>     </tr>      <tr>         <td>3493900</td>         <td><button id="button-22" class="custom-action" value="xy231" name="info">click</button></td>     </tr> </tbody> </table> 

and code looks this:

  $('button').each(function() {     $(this).click(function() {       alert($(this).val());     }   }); 

but, clicking on nothing @ all? using incorrectly?

you can bind buttons click event this, there no need loop through them

$(function(){     $("button").click(function() {         alert($(this).attr("value"));     }); }); 

but more precise selector might be:

$(function(){     $("button[id^='button-'").click(function() {         alert($(this).attr("value"));     }); }); 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -