Did you put it in the "on document ready" function as Igor showed?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I will try to explain in a more detailed way.
You need to add this code in your script:
AJS.toInit(function (){
AJS.$("#description").text("JIRA") //or AJS.$("#description").val("JIRA") - if it input field
});
if this not help, then you can provide more info about a vm file, and we will try to help you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ie a block like this:
(function(){
...
})();
Meaning, run the code in the block when the page is fully parsed and the DOM is available.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Still no effect. I am editing description-edit.vm to add default value. its multi line value , i didnt find multiline character in vm syntax. so using java script. but not able to put value into the description text field..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In vm syntax there is no syntax for it, you just do it like
<textarea>
a
multiline
default
value
</textarea>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
text area seems to be working. but i already hv a txt area. i want to add txt to it. i dont want to create a new txt area..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot Alexy. AJSInit() worked. i had done mistake so it was not working. now it worked gud. solved my prob. thanks again.
thnks for Jamie too, i didnt knw abt this multinline in text area..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I wouldn't say it's "bad" as Alexy suggest, only a bit inconvenient - you can run into conflict between jQuery's $ and Velocity's $" In order to avoid problems, you need to assign $ to another variable:
<script>
(function(){
var q = AJS.$;
q('someselector');
})();
</script>
Of course if you have a large script, it's better extracted into a separate .js file and included on in the .vm via webResourceManager.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Alexy and Igor for your responses. I want to assign default value to description text field using javascript in vm file.
i tried jQuery("#description").text("Jira");
jQuery("#$description").text("Jira");
tried AJS.$("#description").text("Jira");
but not getting value in text field. Am i missing anythin ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If #description is an input or textarea, you need to use val(), not text().
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you put it in the "on document ready" function as Igor showed?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Using Jquery in vm file is bad. But you can use it like that:
<script type="text/javascript">
id = AJS.$("someselector").attr("id")
</script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.
Learn more
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.