Javascript Web Parts

Sherry Collins asked on May 24, 2015 01:34

Does anyone have any experience with javascript webparts and where to place them. I need a script to run in a new/edited blog designer and I am not sure where to place the javascript web part.

I placed it at the root of the blog page and it never seems to see the script. I also tried putting an alert("hello world") and didn't get any from that. My script is below and I have stored it in the Javascript Application.

$(document).ready(function () { $('#BlogPostFeaturedArticle').click(function () { if ($(this).is(":checked")) { $("#BlogPostFeaturedArticleStartDate").datepicker.removeProp('disabled'); $("#BlogPostFeaturedArticleEndDate").datepicker.removeProp('disabled'); } else { $("#BlogPostFeaturedArticleStartDate").dateicker.prop("disabled", true); $("#BlogPostFeaturedArticleEndDate").datepicker.prop("disabled", true); } }); });

Would like to know where I should place the webpart that calls this script.

Thanks.

Correct Answer

Brenden Kehren answered on May 25, 2015 20:32

So are you saying that you want to enable/disable fields based on other selections? If so, you can use some properties already on the field meant for this. Take a look at the "Field advanced settings" section of the field. You can set the visibility and value of a field based on another field. By simply checking the appropriate checkbox and setting a value in another field, you can achieve this.

I might also suggest before posting another question about the same issue to wait until you get answer from your initial question. This just makes it harder for people like myself to answer your question fully and when people search for answers, they end up finding orphaned questions.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on May 25, 2015 18:32

The out of the box JavaScript webparts will NOT run while in any part of the Admin section, they only run on the live site. Also, you will need to include the jQuery library as well that supports what you're attempting to do.

0 votesVote for this answer Mark as a Correct answer

Sherry Collins answered on May 25, 2015 18:53

The screen in question will only be available to the Content Managers from the back end and will not be available to the end users from the live screen.

This screen will be used to add new blogs and add and subtract them from the Featured Article section. The end users will only be able to add a comment from the live site.

So you are saying that my script will never run in Admin. Does Kentico have anything that will disable/enable from the Admin screen

0 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on May 26, 2015 08:06

Extending on what Brenden has advised you, please find these two articles that should really help solve this without writing any javascript code using Kentico dependency fields.

Dependency fields Kentico Article

> Another article

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.