Welcome, Guest
Username: Password: Remember me

TOPIC: [ADDED] JDOM, file

JDOM, file 15 Sep 2013 11:48 #11084

  • Tomaselli
  • Tomaselli's Avatar
  • Offline
  • Elite Member
  • Posts: 293
  • Thank you received: 87
  • Karma: 46
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.
Last Edit: 15 Sep 2013 18:27 by Tomaselli. Reason: added an update
The administrator has disabled public write access.

JDOM, file 19 Sep 2013 12:20 #11122

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
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
The administrator has disabled public write access.

JDOM, file 19 Sep 2013 12:39 #11125

  • Tomaselli
  • Tomaselli's Avatar
  • Offline
  • Elite Member
  • Posts: 293
  • Thank you received: 87
  • Karma: 46
there were no JS errors in the console. it simply didn't work.

firefox 23.0.1
jquery v1.8.3
The administrator has disabled public write access.

JDOM, file 07 Oct 2013 13:17 #11313

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Is it better now ?
Coding is now a piece of cake
The administrator has disabled public write access.

JDOM, file 08 Oct 2013 07:56 #11326

  • Tomaselli
  • Tomaselli's Avatar
  • Offline
  • Elite Member
  • Posts: 293
  • Thank you received: 87
  • Karma: 46
I'll check, I have to generate again the component and add my modifications (except this one).
The administrator has disabled public write access.

JDOM, file 08 Oct 2013 11:16 #11331

  • Tomaselli
  • Tomaselli's Avatar
  • Offline
  • Elite Member
  • Posts: 293
  • Thank you received: 87
  • Karma: 46
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()
	{
	
	}
Last Edit: 08 Oct 2013 11:19 by Tomaselli.
The administrator has disabled public write access.

JDOM, file 08 Oct 2013 17:45 #11337

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
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
The administrator has disabled public write access.

JDOM, file 08 Oct 2013 19:17 #11339

  • Tomaselli
  • Tomaselli's Avatar
  • Offline
  • Elite Member
  • Posts: 293
  • Thank you received: 87
  • Karma: 46
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).
Last Edit: 08 Oct 2013 19:21 by Tomaselli.
The administrator has disabled public write access.

JDOM, file 16 Feb 2014 12:06 #12201

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

JDom is up to date in github too
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: Tomaselli
Time to create page: 0.081 seconds

Get Started