Pregunta

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');
    });
¿Fue útil?

Solución

Based on comments... there were a few issues

  1. some illegal character in the script resource
  2. jQuery was included after the user script
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top