Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Are u really really sure that jquery is loaded? If it is, have you tried $(document).ready(function() { $('#{0}').custSelectBox(); });"?
I am calling th ebelow method at the end in CreateEditControls(). As I told it works fine as a page property. Problem is only when it is set as dynamic property.
private void RegisterResources()
{
if (!Page.ClientScript.IsClientScriptIncludeRegistered("jQuery"))
{
Page.ClientScript.RegisterClientScriptInclude("jQuery", "/CustomProperties/Scripts/jquery-min.js");
}
if (!Page.ClientScript.IsClientScriptIncludeRegistered("dropdownchecklist"))
{
Page.ClientScript.RegisterClientScriptInclude("dropdownchecklist", "/CustomProperties/Scripts/cust_select_plugin.js");
}
Page.ClientScript.RegisterStartupScript(GetType(), "dropdownchecklist-setup" + this.GetHashCode(), string.Format("$('#{0}').custSelectBox();", listBox.ClientID), true);
}
If I change "$('#{0}').custSelectBox();" the to "$(document).ready(function() { $('#{0}').custSelectBox(); });" it gives me invalid string error durin runtime.
You need double {{ }} to wrap the method when doing string.format. $(document).ready(function() {{ .... }});
Hi,
I have a custom property where in I call a jquery plugin with the below code.
Code:
Page.ClientScript.RegisterStartupScript(GetType(), "dropdownchecklist-setup" + this.GetHashCode(), string.Format("$('#{0}').custSelectBox();", listBox.ClientID), true);
This works perfectly when the property is added to any pagetype. But this fails when the property is added as a dynamic property. It fails giving the below error.
$('#ctl00_FullRegion_MainRegion_EditForm_PredefinedLocations_DropdownCheckList').custSelectBox() is not a function.
I have checked that all the required files are being loaded. What might be the problem ? Why is it failing only when called from dynamic properties? SHould I be doing any thing different when loading from dynamic properties?.
Please suggest