|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
using javascript within $ajax->remoteFunctionHello all, I have a textbox that, onblur, needs to use ajax to call an action with its value as a parameter. now ideally this would be accomplished with onblue="<?php echo $ajax->remoteFunction(array('url'=>array ('controller'=>'ratings','action'=>'rateItem',VALUE_GOES_HERE))); ?>" I've tried replacing VALUE_GOES_HERE with 'this.value', this.value, $javascript->codeBlock('this.value') and none of them work properly. It seems like there would be a way to do this with cake. I've currently solved the problem with a work around by taking the javascript code generated by cake and copying and pasting it in place of the $ajax->remoteFunction code. This way I can use this.value. The result looks like this: onblur = "new Ajax.Request('/charity/ratings/rateItem/' + this.value, {asynchronous:true, evalScripts:true})" This works... but I don't like breaking cake convention and it seems as though there should be a "correct" way of doing this. Does anybody know if there is? Thanks in advance! Dave --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@... To unsubscribe from this group, send email to cake-php+unsubscribe@... For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: using javascript within $ajax->remoteFunctionOn Fri, Nov 6, 2009 at 9:52 PM, Dave <davidcroda@...> wrote: > > Hello all, > > I have a textbox that, onblur, needs to use ajax to call an action > with its value as a parameter. > > now ideally this would be accomplished with > > onblue="<?php echo $ajax->remoteFunction(array('url'=>array > ('controller'=>'ratings','action'=>'rateItem',VALUE_GOES_HERE))); ?>" > > I've tried replacing VALUE_GOES_HERE with 'this.value', this.value, > $javascript->codeBlock('this.value') and none of them work properly. > > It seems like there would be a way to do this with cake. I've > currently solved the problem with a work around by taking the > javascript code generated by cake and copying and pasting it in place > of the $ajax->remoteFunction code. This way I can use this.value. > > The result looks like this: > > onblur = "new Ajax.Request('/charity/ratings/rateItem/' + this.value, > {asynchronous:true, evalScripts:true})" > > This works... but I don't like breaking cake convention and it seems > as though there should be a "correct" way of doing this. > > Does anybody know if there is? > > Thanks in advance! With the corresponding view to the remote function call set a variable in a hidden field. And then, in the "oncomplete" attribute, use something like Form.Element.setValue('YourField', $F('HiddenField')); Best regards. -- MARCELO DE F. ANDRADE Belem, PA, Amazonia, Brazil Linux User #221105 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@... To unsubscribe from this group, send email to cake-php+unsubscribe@... For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: using javascript within $ajax->remoteFunctionI'm sorry I think you misunderstood my question
I am trying to figure out how to pass a javascript value from the page which calls the ajax function. I was able to do this by copying and pasting the javascript generated by the CakePHP Ajax helper and modifying it, but I am looking for a way to do this within the framework because from what I gather pretty much anything you need to do you can do with the CakePHP built in methods. On Sat, Nov 7, 2009 at 10:09 AM, Marcelo Andrade <mfandrade@...> wrote:
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@... To unsubscribe from this group, send email to cake-php+unsubscribe@... For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |