Developer forum

Forum » Ecommerce - Standard features » Order field of type date time injects calendar JavaScript

Order field of type date time injects calendar JavaScript

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

In my cart pages I see the following:

<link rel="stylesheet" type="text/css" href="/Admin/Public/DateSelector/calendar-skin.css" />
<script type="text/javascript" src="/Admin/Public/DateSelector/calendar.js"></script>
<script type="text/javascript" src="/Admin/Public/DateSelector/calendar-setup.js"></script>
<script type="text/javascript" src="/Admin/Public/DateSelector/calendar-lang.js.aspx"></script>

It's not specified in the master or layout file. Can this come from an order field of type DateTime? And if so, how do I turn it off?

Thanks,

Imar


Replies

 
Nicolai Høeg Pedersen
Reply

It comes from a order field of type datetime.

When you render the fields, you have 2 tags - one ending with .Clean after the order field system name. If you make a conditional for the date tag and use the .Clean version, you do not get the .js files that comes with the DW control, but just the selected datetime value - and then you can make your own rendering.

BR Nicolai

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi Nicolai,

I changed this Razor code:

if(GetDate("TargetShipDate.Date").Date >= targetShipDate.Date) {

to this:

if(GetDate("TargetShipDate.Date.Clean").Date >= targetShipDate.Date) {

where TargetShipDate is the order field, but the scripts keep being inserted. It's not a big deal (they are small files) but it would be nice to get rid of them.

Imar

 
Nicolai Høeg Pedersen
Reply

Can I get the entire template please?

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Here's the cart template

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

And here's the include it references (which hasd unrelated functionality)

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

I found the following code in Dates.vb:

If HttpContext.Current.Items.Contains("DateselectInclude") Then
    IncludeFiles = False
Else
    HttpContext.Current.Items.Add("DateselectInclude", "True")
End If


So I added the following to my Global.asax:

public void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
  if (Dynamicweb.ExecutingContext.IsFrontEnd())
  {
    HttpContext.Current.Items.Add("DateselectInclude", true);
  }
}

I am adding the key for frontend pages so the date picker doesn't render the include files anmore.

Is this a sensible approach? It works at the frontend, and the datepickers in the backend seem to work fine as well.

Imar

 
Nicolai Høeg Pedersen
Reply

:-). Yes, that is just fine and should work.

As a side note I an tell you that this has died on DW9.

BR Nicolai

 

You must be logged in to post in the forum