I am nearly finished my migration from 1.5 to 2.0 but i have something
failing in my view... basically my view i have an <% and closed %>
I have a inside this this.formatNumber - but it gives an error.. its
not my function, i have put in a breakpoint in the function and it
never arrives
this is the signature
formatNumber: function(theNumber, theDecimals, theSeperator_decimal,
theSeperator_thousands) {
Has something changed in v2.0 to stop me from calling this function in
my controller from the view..??
here is an abtract of my view
<div id="ContentItems" style="float: left; padding: 2px; width:
100%;">
<%
var dailyPrice = this.formatNumber
(data.vehicles[i].dailyPrice, 2, '.', ',').toString().split('.');
var totalPrice = this.formatNumber
(data.vehicles[i].totalPrice, 2, '.', ',').toString().split('.');
I would appreciate any input on this... I think something has changed
but i have tried the docs and forum and don't see any solution.
If i can provide further info.... please let me know..
Thanks in advance..
--
You received this message because you are subscribed to the Google Groups "JavaScriptMVC" group.
To post to this group, send email to javasc...@googlegroups.com.
To unsubscribe from this group, send email to javascriptmv...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/javascriptmvc?hl=en.
I think passing the controller is a bit heavy as i only need the one
function within my controller... so i presume this is why you say i
should be making a view helper..
Sorry to sound dumb, what is a view helper and how do i go about
creating one?
My funciton in my controller is used by my controller also but the
view needs it too..
Any pointers would be really helpful.. I have almost finished with the
migration from 1.5 to 2.0 i think
Thanks
On Dec 21, 3:33 pm, Justin Meyer <justinbme...@gmail.com> wrote:
> You have to pass the controller to the data in 2.0. However, you should be
> making a view helper.
>
> Justin Meyer
>
> Jupiter Consulting
> \Development\Training\Support
> 847-924-6039
> > javascriptmv...@googlegroups.com<javascriptmvc%2Bunsu...@googlegroups.com>
I did check the docs.. and saw some stuff about view helper but it
didn't really help
Also would it be possible to pass in just the function to "data"
rather than the whole controller..
Any help you can offer here woudl be really great
thanks
On Dec 21, 3:33 pm, Justin Meyer <justinbme...@gmail.com> wrote:
> You have to pass the controller to the data in 2.0. However, you should be
> making a view helper.
>
> Justin Meyer
>
> Jupiter Consulting
> \Development\Training\Support
> 847-924-6039
> > javascriptmv...@googlegroups.com<javascriptmvc%2Bunsu...@googlegroups.com>
To unsubscribe from this group, send email to javascriptmv...@googlegroups.com.
I am always a person that tries to follow the rules put in place....
so with your explanation i will now start to create some view
helpers..
Thanks once again.
On Dec 21, 5:34 pm, Justin Meyer <justinbme...@gmail.com> wrote:
> Passing the controller is no more heavyweight then passing the function.
> Remember that almost everything in JS is a pointer/reference. Passing a
> reference to a controller is no different than passing a reference to a
> function.
>
> However, you can also pass the function, but 'this' will be be correct.
>
> On view helpers, these will get populated from your controller. So if you
> have TodoController. You can add helpers like:
>
> TodoController.Helpers = {
> foo : function(){}
>
> }
>
> Your controller actions could reference them like:
>
> click : function(){
> this.Class.Helpers.foo()
>
> }
>
> This is slightly better then passing the funciton or controller b/c it keeps
> straight view formatting code out of the controller (which should really be
> responding to events and manipulating the DOM w/ the help of views.
>
> Justin Meyer
>
> Jupiter Consulting
> \Development\Training\Support847-924-6039
> > <javascriptmvc%2Bunsu...@googlegroups.com<javascriptmvc%252Buns...@googlegroups.com>
and you state i can do this
TodoController.Helpers = {
foo : function(){}
}
I presume this goes in the static section of the controller???
Or do i create a brand new .js file? in the controllers sub directory?
here is my sample v2.0 controller
$.Controller.extend('ReservationContentController',
{
onDocument: true
// SHOULD i add the helper here in the form of
ReservationContentController.Helper?? i presume a coma after the
onDocument:true?
}
},
{
load: function(params) {
.........
On Dec 21, 5:34 pm, Justin Meyer <justinbme...@gmail.com> wrote:
> Passing the controller is no more heavyweight then passing the function.
> Remember that almost everything in JS is a pointer/reference. Passing a
> reference to a controller is no different than passing a reference to a
> function.
>
> However, you can also pass the function, but 'this' will be be correct.
>
> On view helpers, these will get populated from your controller. So if you
> have TodoController. You can add helpers like:
>
> TodoController.Helpers = {
> foo : function(){}
>
> }
>
> Your controller actions could reference them like:
>
> click : function(){
> this.Class.Helpers.foo()
>
> }
>
> This is slightly better then passing the funciton or controller b/c it keeps
> straight view formatting code out of the controller (which should really be
> responding to events and manipulating the DOM w/ the help of views.
>
> Justin Meyer
>
> Jupiter Consulting
> \Development\Training\Support847-924-6039
> > <javascriptmvc%2Bunsu...@googlegroups.com<javascriptmvc%252Buns...@googlegroups.com>
I have tested calling my helper from my controller with
this.Class.Helpers and it works... but i can't seem to call my helper
from my view -- ??
Also this what i di.. i placed my
ReservationContentController.Helpers in the same file as my
controller but after my controller code, is this bad practice? ...
Where should it go? in its own file, which directory??
$.Controller.extend('ReservationContentController',
{
onDocument: true
},
{
load: function(params) {
//this.Class.Helpers.foo(); // COMMENTED OUT BUT IT DOES
WORK
}
});
ReservationContentController.Helpers = {
foo: function() { alert('hi'); }
}
On Dec 21, 5:34 pm, Justin Meyer <justinbme...@gmail.com> wrote:
> Passing the controller is no more heavyweight then passing the function.
> Remember that almost everything in JS is a pointer/reference. Passing a
> reference to a controller is no different than passing a reference to a
> function.
>
> However, you can also pass the function, but 'this' will be be correct.
>
> On view helpers, these will get populated from your controller. So if you
> have TodoController. You can add helpers like:
>
> TodoController.Helpers = {
> foo : function(){}
>
> }
>
> Your controller actions could reference them like:
>
> click : function(){
> this.Class.Helpers.foo()
>
> }
>
> This is slightly better then passing the funciton or controller b/c it keeps
> straight view formatting code out of the controller (which should really be
> responding to events and manipulating the DOM w/ the help of views.
>
> Justin Meyer
>
> Jupiter Consulting
> \Development\Training\Support
> 847-924-6039
> > <javascriptmvc%2Bunsu...@googlegroups.com<javascriptmvc%252Buns...@googlegroups.com>
To unsubscribe from this group, send email to javascriptmv...@googlegroups.com.