Wednesday, January 18, 2012

jasmine-jquery widgets do not need to be cast to variables

<script type="text/javascript">

   (function () {

      $(document).ready(function () {

         var filterForm = $('#formfiltering');

         var pager = $('#pager');

         var widget = pager.PagerWidget({

            form: filterForm,

            page: @Model.ListView.Page,

            pageSize: @Model.ListView.PageSize

         });

         var foo = widget.PagerWidget('getOption', 'pageSize');

         alert(foo);

      });

   })();

</script>

 
 

The above, can be made simpler or more complicated (depending on your perspective) like so:

<script type="text/javascript">

   (function () {

      $(document).ready(function () {

         var filterForm = $('#formfiltering');

         var pager = $('#pager');

         pager.PagerWidget({

            form: filterForm,

            page: @Model.ListView.Page,

            pageSize: @Model.ListView.PageSize

         });

         var foo = pager.PagerWidget('getOption', 'pageSize');

         alert(foo);

      });

   })();

</script>

No comments:

Post a Comment