Re: [Dev] How to add HTML elements and JS functions dynamically

2014-08-12 Thread Danushka Fernando
Hi Samith
As we discussed offline you can set the value of select item to the file
name and at the onselect event you can load that particular js and call
some function in it. But there needs to be a function with same name in
each file to make it work.

Thanks  Regards
Danushka Fernando
Software Engineer
WSO2 inc. http://wso2.com/
Mobile : +94716332729


On Tue, Aug 12, 2014 at 10:27 AM, Samith Dassanayake sam...@wso2.com
wrote:

 Hi,
 I have a form with a drop down element. Based on the selected value of the
 drop down I want to dynamically add form elements from a another file,
 which contains the remaining form elements and validation functions for
 those elements. For each value in the drop down, we have a separate file
 which contains the remaining part of the form and validation function based
 on the selected drop down value.
 Is it possible to dynamically load elements and functions as above
 scenario? If is it possible what the best way to do it?

 Thanks

 --
 Best Regards

 Samith Dassanayake
 Software Engineer, WSO2 Inc.


 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev


___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] How to add HTML elements and JS functions dynamically

2014-08-12 Thread Udara Rathnayake
Hi Samitha,


On Tue, Aug 12, 2014 at 10:27 AM, Samith Dassanayake sam...@wso2.com
wrote:

 Hi,
 I have a form with a drop down element. Based on the selected value of the
 drop down I want to dynamically add form elements from a another file,
 which contains the remaining form elements and validation functions for
 those elements.


Why do you need to keep separate files? Since these are just form elements
you can dynamically generate these fields and render. Are these validation
functions specific to this scenario?
If there are common stuff you should keep those away from front-end HTML so
you can re-use.


 For each value in the drop down, we have a separate file which contains
 the remaining part of the form and validation function based on the
 selected drop down value.
 Is it possible to dynamically load elements and functions as above
 scenario? If is it possible what the best way to do it?

 Thanks

 --
 Best Regards

 Samith Dassanayake
 Software Engineer, WSO2 Inc.


 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




-- 
*Udara Rathnayake*
Software Engineer
WSO2 Inc. : http://wso2.com

Mobile : +94 772207239
Twitter : http://twitter.com/udarakr
Blog: http://udarakr.blogspot.com
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] How to add HTML elements and JS functions dynamically

2014-08-12 Thread Dakshika Jayathilaka
Hi,

if your using jquery, you can use $.getScript() [1] for this type of
dynamic js loading.

[1] http://api.jquery.com/jQuery.getScript/

*Dakshika Jayathilaka*
Software Engineer
WSO2, Inc.
lean.enterprise.middleware
0771100911


On Wed, Aug 13, 2014 at 2:41 AM, Udara Rathnayake uda...@wso2.com wrote:

 Hi Samitha,


 On Tue, Aug 12, 2014 at 10:27 AM, Samith Dassanayake sam...@wso2.com
 wrote:

 Hi,
 I have a form with a drop down element. Based on the selected value of
 the drop down I want to dynamically add form elements from a another file,
 which contains the remaining form elements and validation functions for
 those elements.


 Why do you need to keep separate files? Since these are just form elements
 you can dynamically generate these fields and render. Are these validation
 functions specific to this scenario?
 If there are common stuff you should keep those away from front-end HTML
 so you can re-use.


  For each value in the drop down, we have a separate file which contains
 the remaining part of the form and validation function based on the
 selected drop down value.
 Is it possible to dynamically load elements and functions as above
 scenario? If is it possible what the best way to do it?

 Thanks

 --
 Best Regards

 Samith Dassanayake
 Software Engineer, WSO2 Inc.


 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 *Udara Rathnayake*
 Software Engineer
 WSO2 Inc. : http://wso2.com

 Mobile : +94 772207239
 Twitter : http://twitter.com/udarakr
 Blog: http://udarakr.blogspot.com


 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev


___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] How to add HTML elements and JS functions dynamically

2014-08-12 Thread Samith Dassanayake
Hi Udara,
We are keeping them in separate files because drop down values can be added
dynamically. Based on the selected value remaining part of the form need to
be changed and the validations of the those elements should be loaded
dynamically.
As a solution we can use JQuery.getscript()[1] or load them using eval() by
passing external script content as an argument with a representation object.

[1] http://api.jquery.com/jQuery.getScript/


On Wed, Aug 13, 2014 at 8:11 AM, Udara Rathnayake uda...@wso2.com wrote:

 Hi Samitha,


 On Tue, Aug 12, 2014 at 10:27 AM, Samith Dassanayake sam...@wso2.com
 wrote:

 Hi,
 I have a form with a drop down element. Based on the selected value of
 the drop down I want to dynamically add form elements from a another file,
 which contains the remaining form elements and validation functions for
 those elements.


 Why do you need to keep separate files? Since these are just form elements
 you can dynamically generate these fields and render. Are these validation
 functions specific to this scenario?
 If there are common stuff you should keep those away from front-end HTML
 so you can re-use.


  For each value in the drop down, we have a separate file which contains
 the remaining part of the form and validation function based on the
 selected drop down value.
 Is it possible to dynamically load elements and functions as above
 scenario? If is it possible what the best way to do it?

 Thanks

 --
 Best Regards

 Samith Dassanayake
 Software Engineer, WSO2 Inc.


 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 *Udara Rathnayake*
 Software Engineer
 WSO2 Inc. : http://wso2.com

 Mobile : +94 772207239
 Twitter : http://twitter.com/udarakr
 Blog: http://udarakr.blogspot.com




-- 
Best Regards

Samith Dassanayake
Software Engineer, WSO2 Inc.
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[Dev] How to add HTML elements and JS functions dynamically

2014-08-11 Thread Samith Dassanayake
Hi,
I have a form with a drop down element. Based on the selected value of the
drop down I want to dynamically add form elements from a another file,
which contains the remaining form elements and validation functions for
those elements. For each value in the drop down, we have a separate file
which contains the remaining part of the form and validation function based
on the selected drop down value.
Is it possible to dynamically load elements and functions as above
scenario? If is it possible what the best way to do it?

Thanks

-- 
Best Regards

Samith Dassanayake
Software Engineer, WSO2 Inc.
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev