Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

JDOM, file 15 Sep 2013 11:48 #11084

scenario:
fresh joomla installation j3.x
fresh component (no hacks), just added few more fields manually in the form.xml.

the JDOM.html.form.input.file doesn't work properly on a j3.x installation with bootstrap.
Firstly the trigger to select the file doesn't work (line 394) then after fixed that, the "fake" bootstrap input field is not updated when I select the file (line 429).

on the file: administrator\components\com_mycomponent\dom\html\form\input\file\default.php
the line 394 and 429:

394:
		'link_js' => 'jQuery(\'input[id=' . $id . ']\').click();',

429:
		$js = "jQuery('input[id=" . $id . "]').change(function() {

for some reason (I didn't investigate yet) it doesn't work to me.

but it perfecly works if I change to (what should be the same):

394:
		'link_js' => 'jQuery(\'input[id=' . $id . ']\').trigger('\'click\);',

429:
		$js = "jQuery('input[id=" . $id . "]').on('change', function() {


UPDATE:
after I added those modifications, if I have more file fields in the form ONLY the first work, I don't know for what reason (too tired today to investigate why), I had to modify the line 407, adding the following code (the default addscriptdeclaration didn't work, it works only ONCE):
		$html .="
		<script type=\"text/javascript\">
		jQuery(document).ready(function(){
			jQuery('input[id=" . $id . "]').on('change', function() {
				jQuery('#" . $idView . "').val(jQuery(this).val());
			});
		});
		</script>
		";

and bypass the function buildJs() , in this way everything works. tomorrow I'll take a look more deeply why.

Please Log in or Create an account to join the conversation.

Last edit: by Tomaselli. Reason: added an update

JDOM, file 19 Sep 2013 12:20 #11122

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
I cannot see this one...

Which browser are you using ?
Do you have a JS error ?

This is strange did you tried with the last jQuery stable release ?
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

JDOM, file 19 Sep 2013 12:39 #11125

there were no JS errors in the console. it simply didn't work.

firefox 23.0.1
jquery v1.8.3

Please Log in or Create an account to join the conversation.

JDOM, file 07 Oct 2013 13:17 #11313

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Is it better now ?
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

JDOM, file 08 Oct 2013 07:56 #11326

I'll check, I have to generate again the component and add my modifications (except this one).

Please Log in or Create an account to join the conversation.

JDOM, file 08 Oct 2013 11:16 #11331

the hidden file input trigger works, but all the rest don't work.
By the way I suggest you this modification and little improvements:

from line 362
		//Create hidden input (file)
		$onchange = "jQuery(this).closest('div').find('#" . $idView . "').val(jQuery(this).val());";
		$htmlInputHidden = '<input onChange="'. $onchange .'" type="file" id="<%DOM_ID%>" name="<%INPUT_NAME%>" ' 
			. ' style="display:none;"'
			.	' value="<%VALUE%>"'
			.	'/>' .LN;	
		
		//Create a visible text field (stylable)
		$onFocus = 'jQuery(this).closest(\'div\').find(\'input[id=\"' . $id . '\"]\').trigger(\'click\');';
		$dom = JDom::getInstance('html.form.input.text', array(
			'dataValue' => $this->dataValue, //Uncomment if you want to prefill the input with current value
			'domId' => $idView,
			'selectors' => array('onFocus' => $onFocus, 'readonly'=>'') /* hack */
		));

and:
	function buildJs()
	{
	
	}

Please Log in or Create an account to join the conversation.

Last edit: by Tomaselli.

JDOM, file 08 Oct 2013 17:45 #11337

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
I have added you proposal. K++ (You got a lot of karma recently...lol)

About removing the buildJs() I say no because it permits to show the selected filename. Chrome is adding 'c:\fakepath', but it is not a bug. It is a security.

I tried on Firefox same version than you.
It is working for me. I cannot find it.
Wich PTL ? I will try your project.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

JDOM, file 08 Oct 2013 19:17 #11339

I just moved the build js directly into the onchange of the hidden input field.
		//Create hidden input (file)
		$onchange = "jQuery(this).closest('div').find('#" . $idView . "').val(jQuery(this).val());";
		$htmlInputHidden = '<input onChange="'. $onchange .'" type="file" id="<%DOM_ID%>" name="<%INPUT_NAME%>" ' 
			. ' style="display:none;"'
			.	' value="<%VALUE%>"'
			.	'/>' .LN;

in this way it is also compatible with dynamic JS cloning features (to add multiple instances of the same input).

Please Log in or Create an account to join the conversation.

Last edit: by Tomaselli.

JDOM, file 16 Feb 2014 12:06 #12201

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Added now (JDom 2.6.3)

JDom is up to date in github too
Coding is now a piece of cake
The following user(s) said Thank You: Tomaselli

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.076 seconds

I'm playing around with the new mvc and the FORK feature is FANTASTIC!!! it's saving me a lot of time! you are doing a very good job!!

Tomaselli (Forum)  

Get Started