by Jeff Handley via Jeff Handley on 4/13/2011 9:42:41 PM
Today at MIX11, Brad Olenick announced RIA/JS, a jQuery client for WCF RIA Services. This is an early preview that we want to get your feedback on. Long before WCF RIA Services V1.0 was released, we started talking RIA Services support for AJAX; in fact, you can see the item here on the RIA Services Wish List (11th ranked as of today). We hope that you’ll grab this preview and let us know if you like the direction we’re going.
In today’s state the features are somewhat limited, but many of the basic scenarios are in place:
This jQuery client is broken up into several script files. The factoring of these files will likely change with subsequent releases.
There are a few other script files that you will need to use as well:
The RIA/JS library is available in two forms:
Update: As of the August 2011 drop of RIA/JS, this walkthrough is now obsolete. jquery.array.js and jquery.datalink.js are no longer included in RIA/JS; instead, we have jquery.observable.js included. Additionally, the August 2011 preview works with jQuery 1.5.1+ instead of 1.4.4.
For an updated walkthrough, please refer to the WCF CodePlex site where the BigShelf application is used.
Let’s walk through a super quickstart that illustrates how to query and submit data through the jQuery client.
[EnableClientAccess()]public class CustomerService : DomainService{ public IQueryable<Customer> GetCustomers() { return new[] { new Customer { CustomerId = 1, CustomerName = "John Doe" } }.AsQueryable(); } public void UpdateCustomer(Customer customer) { }} public class Customer{ [Key] public int CustomerId { get; set; } public string CustomerName { get; set; }}
<script src="/Scripts/DataContext.js" type="text/javascript"></script><script src="/Scripts/DataSource.js" type="text/javascript"></script><script src="/Scripts/DomainServiceProxy.js" type="text/javascript"></script><script src="/Scripts/EntitySet.js" type="text/javascript"></script><script src="/Scripts/jquery.array.js" type="text/javascript"></script><script src="/Scripts/jQuery.DataLink.js" type="text/javascript"></script><script src="/Scripts/jquery.datasource.js" type="text/javascript"></script><script src="/Scripts/RemoteDataSource.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { var serviceUrl = "/CustomerApp-CustomerService.svc"; var customers = []; var render = function (loadedCustomers) { $("#customerForm input[name='CustomerName']").val(loadedCustomers[0].CustomerName); $("#customerForm").link(loadedCustomers[0]); }; $([customers]).dataSource({ serviceUrl: serviceUrl, queryName: "GetCustomers", refresh: render }).refresh(); }); </script> <div id="customerForm"> Name: <input type="text" name="CustomerName" /></div>
$([customers]).dataSource({ serviceUrl: serviceUrl, queryName: "GetCustomers", bufferChanges: true, refresh: render}).refresh();
<input type="button" value="Update Customer" id="submit" />
$("#submit").click(function () { $([customers]).dataSource().commitChanges();});
We will be publishing more details about this new jQuery client for WCF RIA Services. You can also find more information and the BigShelf sample application at http://jeffh.me/wcfjquery.
Original Post: RIA/JS - jQuery client for WCF RIA Services
The content of the postings is owned by the respective author. Silverlight Feeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on Silverlight Feeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.