> I'm stuck.
> I am able to successfully insert data into the Authors_By_Group table in the DB - but what seems to be happening is that the whole CMS system is reloaded every time I press the "Add Group" button. I would simply like the new group assignment to be written to the DB and stay on the same page and tab. (I have yet to write the code to display the current groups assigned to the page.) I am fairly certain it isn't running the javascript I have created - using the javascript written for the "save" function.
> Is there an easier way to do this? Am I on the right track? Thanks in advance.
Hi Hani,
To prevent who page reloads, you need to do Javascript AJAX requests, for example I wrote this function in the gsoc branch:
// Called when checkbox on Bounced tab of Mailing List is clicked
Behaviour.register( {
'#BouncedListTable tr td.markingcheckbox input': {
onchange : function(e) {
new Ajax.Request(
'admin/newsletter/memberblacklisttoggle/' + this.value,
{
method: 'post',
postBody: 'forceajax=1',
onComplete: function(response){
Ajax.Evaluator(response);
}.bind(this),
onFailure: ajaxErrorHandler
}
);
}
}
});
One thing I would do is try putting stuff like:
alert('yes, this js code was called');
// or if you have the Firebug extension for Mozilla Firefox
console.log('yes, this code ran');
to see if your Javascript code is running.
However, you may want to use Debug.log('test'); instead of console.log, because of this (I have not tried it yet though):
Please use the Debug-class rather than console.log for outputting debug-information
Debug.show(<anyobject>)
Debug.log(<anyobject>)
http://doc.silverstripe.com/doku.php?id=javascript#debugging_javascript_in_silverstripe
I have put trying out your code and trying to help you more on my SilverStripe To Do list and I will try to help you more today if I finish working on this bug today: Ticket #1370: Behaviour is not applied with ajax in IE
Hope this helps,
Elijah Lofgren