Hi All
My question is about admin section. I have a custom page with set of fields. One of them is «Tags» with many-to_many relation. So I have list with my tags and I can select a few of them without problem. But also I need to add new tag without reloading the page. I guess Ajax is good for this. I am familiar with Ajax, Javascript, PHP but I have no idea how to do that with Silverstripe.
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
The night gone but i sttill search for way to do that.
Is there any tutorial or doc how Silverstripe build his path to objects?
I mean, for example, if I edit my page of type ArticlePage with path /admin/pages/edit/show/7 so how can I access controller of this page rather function GetList() from this controller?
yop.
Not sure the thread is still up, but basically, to run an ajax request in SS3, this is how I did :
Include your JS in the "getCMSFields" function of your controller :
class MyController extends Page{
public function getCMSFields() {
Requirements::javascript('mysite/javascript/javascript.js');
}
}
This file will be loaded on pages of type "MyControrller".
In the javascript.js (that's an example. I call an ajax request everytime I change the value of a dropdownfield) :
jQuery(document).ready(function($) {
$.entwine('ss', function($){
$("#Form_EditForm_MarqueID").entwine({
onchange : function() {
//alert(this.val());
$.ajax({
url: '/mysite.be/myadmin/getModels?marqueid='+this.val(), //mysite.be refers to your website of course.
type:'GET',
success: function(){
console.log('it worked);
},
error: function(){
console.log('it failed');
}
});
}
});
});
});
I hope I answered your question.
EDIT : I found a usefull thread, even if it's old, I think it can be useful :) http://www.silverstripe.org/customising-the-cms/show/7893