I don't know a lot about jQuery, and I want know how do I reload all the functions of jQuery after a ajax call, because I add element in a and then the new element don't work but the others work fine.
The ajax call:
$(document).ready(function () {
$('#search-bar').keyup(function (event) {
if (event.keyCode == 13) {
myFunction();
}
});
var city = $('#search-bar').val();
$.ajax({
url: '@Url.Action("getWeatherSearch", "Index")',
data: { city: city },
//async: false,
error: function (resp) {
var div = document.getElementById('rb-grid');
div.innerHTML = resp.responseText + div.innerHTML;
},
success: function (resp) {
$("#rb-grid").prepend(resp);
}
});
HTML:
The textbox: @Html.TextBox("search-bar", "", new { @class = "search-bar", placeholder = "Pesquisar" })
This is where I wnat to add the new
<ul id="rb-grid" class="rb-grid clearfix">
<li class="icon-clima-1 rb-span-2">
<h3>@ViewBag.CurrentCity</h3><span class="rb-temp">@ViewBag.CurrentTemp°C</span>
<div class="rb-overlay">
<span class="rb-close">close</span>
<div class="rb-week">
<div><span class="rb-city">@ViewBag.CurrentCity</span><span class="icon-clima-1"></span><span style="font-size: 60px !important;">@ViewBag.CurrentTemp ºC</span><span style="font-size: 40px !important;">Min: @Next0.tempMinC ºC</span></div>
<div style="width: 17.5%;"><span>@Next1.date.DayOfWeek.ToString().Substring(0, 3)</span><span class="icon-clima-1"></span><span style="font-size: 40px !important;">Max: @Next1.tempMaxC ºC <br /><br /> Min: @Next1.tempMinC ºC</span></div>
<div style="width: 17.5%;"><span>@Next2.date.DayOfWeek.ToString().Substring(0, 3)</span><span class="icon-clima-1"></span><span style="font-size: 40px !important;">Max: @Next2.tempMaxC ºC <br /><br /> Min: @Next2.tempMinC ºC</span></div>
<div style="width: 17.5%;"><span>@Next3.date.DayOfWeek.ToString().Substring(0, 3)</span><span class="icon-clima-1"></span><span style="font-size: 40px !important;">Max: @Next3.tempMaxC ºC <br /><br /> Min: @Next3.tempMinC ºC</span></div>
<div style="width: 17.5%;"><span>@Next4.date.DayOfWeek.ToString().Substring(0, 3)</span><span class="icon-clima-1"></span><span style="font-size: 40px !important;">Max: @Next4.tempMaxC ºC <br /><br /> Min: @Next4.tempMinC ºC</span></div>
</div>
</div>
</li>
this is how I activate Boxgrid:
<script>
$(function () {
Boxgrid.init();
});
</script>