I am wanting to dynamically set the params in a remoteFunction within a check box. I have tried lots of different combinations I’ll show a couple below but I just recieve error like below…
so it basically my theory, in the scope of this method doesn’t have a clue what an eventInstance is
In FireBug error console I receive ReferenceError: eventInstance is not defined
Test Combination 1
<g:checkBox name='completed' value="${eventInstance.completed}"
onclick="${remoteFunction(action:'update', id:eventInstance.id, params:'\'id=\' + eventInstance.id+\'&version=\' + eventInstance.version' , onComplete: "tester()" )}" />
Test Combination 2
<g:checkBox name='completed' value="${eventInstance.completed}" evt="${eventInstance}"
onclick="${remoteFunction(action:'update', id:eventInstance.id, params:"[version=evt.version, editType='occurrence', title=evt.title, startTime=start, endTime=end, isRecurring=evt.isRecurring, completed='true']", onComplete: "tester()" )}" />
This works if manually entering i.e. hard-coding the data in but this is no use. Something silly which I just can’t find the answer to 🙁
OK for this to work … seems somewhat strange, you CAN NOT use grails variables i.e. sent from controller to use in GSP
Instead … you HAVE TO save the variables into a JavaScript variable.
So for each of the variables I wanted to use from the
eventInstanceto use in theparamsi.e. id, version, any other fields contained within I simply did the following:then referenced these variables in the params section of the
remoteFunctionlike follows:Not sure if this is some kind of bug or simply something wrong in my approach, however I have tried every single combination possible and seems the only work around solution I could come up with