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.

javascript - JQuery how to click div inside li to update another div -


i have ul appending li's 2 div's through javascript it, shown below

c_list = $('.encounter_creatures_list > ul')   db.transaction(     function(transaction) {         transaction.executesql(           'select * creatures;',           [],              function (transaction, result) {                var creature_array = new array();                (i=0; < result.rows.length; i++){                  var row = result.rows.item(i)                li = $("li[key='" + row.id + "']")                      if(li.length > 0) {                        // $('#name', li).html(encounter.name)                      } else {                       creature_array.push(row)                        var counter = 0                            li = $("<li key='"+ row.id + "' class='list_"+ row.id + "'>"+ row.name +  "<div class='plus_"+ row.id + "'>+</div> <div class='counter_"+ row.id + "'>"+ counter  +"</div></li>")                         li.css({'border': '1px solid #999999', 'color': '#222222', 'display': 'block', 'font-size': '17px', 'font-weight': 'bold', 'margin-bottom': '-0.5px', 'padding': '12px 10px', 'text-decoration': 'none'})                        c_list.append(li)        //                           alert($(".counter_"+ row.id + "", li).text())  //                           $(".plus_"+ row.id + "", li).click(function(event) { //                              $(".counter_"+ row.id + "", li).text(counter + 1) //                             event.preventdefault(); //                           })                      }                 }              })        })  

i want part have commented, i.e. clicking 1 div update inside li.

add class div static. add onload event. elements class .classname have onclick functionality.

$(".classname").live("click", function() {   var rowid = $(this).attr("key");   alert($(".counter_"+ rowid, li).text());   $(".counter_"+ rowid, li).text(counter + 1); }); 

one side note. code bit messy. should try refactor bit.


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 -