7921 Posts in 1359 Topics by 933 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » JavaScript in the DOM popup
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 490 Views |
-
JavaScript in the DOM popup

5 October 2012 at 3:19am Last edited: 15 October 2012 11:22pm
Hi
I am using 2.4.7 and want to add some javascript to the DOM popup. Basically what I want to happen is that when a certain value in a dropdown box is selected, another field appears (a textfield in this case).
I tried this tutorial but had absolutely no success.
I would be over the moon if someone could give me a hint about it. It is driving me crazy.
Thanks
Edit
My attempts have been as unsuccessful as when I posted this but here is my code anyway.
(function($) {
$(document).ready(function(){
var dropDown = $('#DataObjectManager_Popup_DetailForm_Status');
var reason = $('#DataObjectManager_Popup_DetailForm_Reason');if(dropDown.val() == 'rejected' || 'Rejected'){
reason.show();
}
else{
reason.hide();
};dropDown.change(function (e) {
if(dropDown.val() == 'rejected' || 'Rejected'){
reason.show();
alert(dropDown.val())
}
else{
reason.hide();
}
})
});
})(jQuery);The reason textfield disappears as it is supposed to when I hit save but not when the dropdown is changed.
-
Re: JavaScript in the DOM popup

15 October 2012 at 11:22pm
11 days and 143 views later nobody has any advice?
From my investigations it turns out that the Javascript is being called ok but the change part is not being applied. I'm stumped as to why not?
-
Re: JavaScript in the DOM popup

16 October 2012 at 3:50pm
Check your script.
if(dropDown.val() == 'rejected' || 'Rejected'){
reason.show();
}^^ This always returns true, Because "Rejected" is a string with > 0 length, it is always evaluated as true.
---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com -
Re: JavaScript in the DOM popup

16 October 2012 at 9:00pm
Thank you so much. I can't believe I was stuck on something so simple.
| 490 Views | ||
|
Page:
1
|
Go to Top |

