Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Support for ajax in alphabetical search
Browse files Browse the repository at this point in the history
  • Loading branch information
iloire committed Oct 3, 2011
1 parent 9424779 commit 2b509f8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
**0.10**

* Added DueDate field to invoice.
* Some bug fixing.
* Some bug fixing.
* Alphabetical and "by name" search in Customer.
* Support for ajax in alphabetical search.

**0.9**

Expand Down
9 changes: 6 additions & 3 deletions iloire Facturacion/Controllers/CustomerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ public class CustomerController : Controller
private DBContext db = new DBContext();

/*CUSTOM*/
public ViewResult Search(string q)
public ViewResultBase Search(string q)
{

var customers = new List<Customer>();
if (q.Length == 1)
{
Expand All @@ -32,7 +31,11 @@ where c.Name.StartsWith(q)
where c.Name.IndexOf(q)>-1
select c).ToList();
}
return View("Index",customers);

if (Request.IsAjaxRequest())
return PartialView("Index", customers);
else
return View("Index", customers);
}

/*END CUSTOM*/
Expand Down
21 changes: 20 additions & 1 deletion iloire Facturacion/Views/Customer/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,30 @@
ViewBag.Title = "Index";
}

<div id="ajaxReponse">

<h1>List <small>of Customer</small></h1>

<p>
@Html.ActionLink("Create New", "Create", null, new {@class="btn"})
</p>

<script type="text/javascript">
$(document).ready(function () {
$("ul.filtroAlfab a").click(function (e) {
$.ajax({ url: this.href, success: function (data) {
$("#ajaxReponse").html(data);
}
});
return false;
});
});
</script>





<ul class="filtroAlfab">
@foreach (var letra in "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ")
{
Expand Down Expand Up @@ -81,4 +99,5 @@
</tr>
}

</table>
</table>
</div>

0 comments on commit 2b509f8

Please sign in to comment.