-1

in my asp page i have a table as below, it has some dynamic elements, i want to do my job when input fields of my table changes

@{var table = (DataTable)HttpContext.Current.Session["basket"];}
<table class="zebra">
        <thead>
            <tr>
                @foreach (System.Data.DataColumn col in table.Columns)
                {          
                    <th>@col.ColumnName</th> 
                }
                <th>İşlem</th>
            </tr>
        </thead>
        <tbody>    
            @foreach (System.Data.DataRow row in table.Rows)
            {                
                <tr>
                    @foreach (System.Data.DataColumn col in table.Columns)
                    {
                        if (col.ColumnName == "quantity")
                        {
                           <td> <input class="quantityInput" type="number" value="@row[col.ColumnName]" min="1"/></td>
                        }
                        else if (col.ColumnName == "price")
                        {              
                        <td>@((Convert.ToInt32(row["quantity"])) * Convert.ToDecimal(row[col.ColumnName]))</td>
                        }
                        else
                        {
                            <td>@row[col.ColumnName]</td>
                        }                                                                                                                                                                                      
                    }
                    <td><a href="@Url.Action("DeleteBasketItem", "Home", new {id = row["id"].ToString()})">Sil</a></td>    
                </tr>                     
            }    
        </tbody>
    </table>

but my script does not work and i dont know why, i tried

$(document.body).on('change', '.quantityInput' ,function(){
    alert('123');
});

and

$(".quantityInput").on('change' ,function(){
        alert('123');
    });
Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
hmz
  • 1,017
  • 9
  • 18
  • any error in the browser console – Arun P Johny Aug 01 '13 at 10:55
  • Uncaught SyntaxError: Unexpected token ILLEGAL chrome.tabs is not available: You do not have permission to access this API. Ensure that the required permission or manifest property is included in your manifest.json. Binding.generate Uncaught TypeError: Cannot call method 'create' of undefined – hmz Aug 01 '13 at 10:57
  • 1
    check your script files to see whether there is any illegal characters http://stackoverflow.com/questions/5733275/chrome-uncaught-syntax-error-unexpected-token-illegal and http://stackoverflow.com/questions/12719859/syntaxerror-unexpected-token-illegal – Arun P Johny Aug 01 '13 at 10:59
  • there was one, but still not working – hmz Aug 01 '13 at 11:13
  • Uncaught ReferenceError: $ is not defined _OrderBasketView:106 (anonymous function) _OrderBasketView:106 chrome.tabs is not available: You do not have permission to access this API. Ensure that the required permission or manifest property is included in your manifest.json. [VM] binding (1665):216 Binding.generate [VM] binding (1665):216 (anonymous function) [VM] tabs (1704):43 (anonymous function) measureIt.js:120 Uncaught TypeError: Cannot call method 'create' of undefined measureIt.js:120 (anonymous function) – hmz Aug 01 '13 at 11:14
  • Do you have jQuery added to the page – Arun P Johny Aug 01 '13 at 11:15
  • yes, at the bottom of the page – hmz Aug 01 '13 at 11:16
  • is it added before your script is included – Arun P Johny Aug 01 '13 at 11:16
  • it is not added before my script is included – hmz Aug 01 '13 at 11:18
  • 1
    it should be included before your script, yours uses jQuery also you have to wrap your code in dom ready event – Arun P Johny Aug 01 '13 at 11:19

1 Answers1

0

Based on comments... there were a few issues

  1. some illegal character in the script resource
  2. jQuery was included after the user script
Arun P Johny
  • 384,651
  • 66
  • 527
  • 531