Welcome, Guest
Username: Password: Remember me

TOPIC: Jquery : id, name or else, for an ajax combo

Jquery : id, name or else, for an ajax combo 04 Oct 2012 18:53 #4258

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
	  vehicule += jQuery("select#jform_vehicule").val();
	  jQuery("#vehicule").html(vehicule);
this works flawless. But what if I want to get the value of an ajax group by field ? Can't seem to find the right one
Thanks for your help
Last Edit: 04 Oct 2012 18:54 by VeCrea.
The administrator has disabled public write access.

Re: Jquery : id, name or else, for an ajax combo 05 Oct 2012 06:46 #4261

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Try this to see if you're getting what you need/expect by either placing this .ready function in the head or, placing the inner function in an existing ready function..:
jQuery(document).ready(function() {
    $("#my-select).change(function() { //Change the #my-select on this line and below
        alert($('#my-select option:selected').html());
    });
});
From looking at the dom structure of one of my ajax fields, each new subsequent groupby elements' id changes to represent its relation...

What I mean is, in my ajax combo, I have 3 elements;
  1. Country: jform_county_region_country
  2. Region: jform_county_region
  3. County: jform___ajx_county

Hope this helps!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: Jquery : id, name or else, for an ajax combo 05 Oct 2012 06:58 #4263

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
Thanks I tried much combinations already, nothing has worked... Will try again though, but...can't seem to find the right id for the ajax fields
Last Edit: 05 Oct 2012 07:00 by VeCrea.
The administrator has disabled public write access.

Re: Jquery : id, name or else, for an ajax combo 05 Oct 2012 08:10 #4266

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
From looking at the dom, they should be as follows:
  1. If you've specified a groupby field and the combo only has 2 levels the first select box will follow the format;
    jform_foreignField1_fieldFromTable where
    • foreignField1 = the field you've used as the label from your foreign table
    • fieldFromTable = the FK field you've placed in the table
    and the 2nd combobox will follow the format;
    jform__ajx_fieldname where fieldname = the name of the field you are using the combobox for
  2. if you have a second level group by (as in if you are drilling down into a 3rd table) it will work just as above except that it will add an extra _foreignField2 to the first combo box so it will look like;
    jform_foreignField1_foreignField2_fieldFromTable[/i][/b] where
    • foreignField1 = the field you've used as the label from your foreign table
    • foreignField2 = the field you've used as the label from your second foreign table
    • fieldFromTable = the FK field you've placed in the table
    • The
    2nd combo box in this instance will look like the 1st combo in No. 1 and the second will look like the 2nd combo in No. 1 with the addition of another underscore prepended to the "ajx" part of the combo id
Hope this helps narrow it down!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
Last Edit: 05 Oct 2012 08:11 by JoomGuy.
The administrator has disabled public write access.

Re: Jquery : id, name or else, for an ajax combo 05 Oct 2012 10:39 #4270

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
ToolTips are on the way.

A drafted JDom Tooltip is already existing in local, but not finished because I want to implement it for every children of html.fly and html.grid.

Bit of patience, it is comming.
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: JoomGuy

Re: Jquery : id, name or else, for an ajax combo 06 Oct 2012 10:11 #4288

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
Well it doesn't work for me... Tried every combination... I was able to get it to work with every input and select, but not with ajax combos.
Even the simpliest thing like
		jQuery("select#jform_jobcat_jobtype").change(function () {
			jQuery("#jobtype").html("test");
			})
			.change();
doesn't get the jobtype div to change.
And i tried many other #'s
The administrator has disabled public write access.

Re: Jquery : id, name or else, for an ajax combo 07 Oct 2012 19:58 #4310

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi,

I think in the change event handler, you're going to have to set the value or selected value to the Id of the value you require. This in-turn should change the text value related to it , ie the title or name from the related table.

Hope this helps!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: Jquery : id, name or else, for an ajax combo 08 Oct 2012 03:31 #4316

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
i thought of adding a class attribute, will check out both our solutions this afternoon.
Thanks
Last Edit: 08 Oct 2012 03:31 by VeCrea.
The administrator has disabled public write access.

Re: Jquery : id, name or else, for an ajax combo 08 Oct 2012 05:34 #4322

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
No probs adding the class attr but it won't add anything as such in terms of making it work/speeding it up as you are already selecting with the id which takes priority.

Hope it helps!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: Jquery : id, name or else, for an ajax combo 08 Oct 2012 05:41 #4323

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
Well, that is the catch. I'm not sure if I select it right or not. It works fine with other selects so I really believe it's a problem of selecting the correct Id. That's why I thought of adding a class there, to make sure of the selector I use
Thanks for helping
The administrator has disabled public write access.

Re: Jquery : id, name or else, for an ajax combo 08 Oct 2012 06:16 #4324

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
One thing that I think you might need to do is check that your selector/change script is firing on the page after the Ajax div wrapper for the combo...

I seem to remember reading somewhere that a JDom class creates the wrapper then the view.html.php page loads the content into it...

Try to use the JS console or at least the source HTML of the page to see when the select options are loaded and ensure your select comes after.

Are you getting any JS errors in console? If I'm right, you should be getting an error telling you that it doesn't exist.

Hope this helps,

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
Last Edit: 08 Oct 2012 07:20 by JoomGuy. Reason: Changed to view.html.php
The administrator has disabled public write access.

Re: Jquery : id, name or else, for an ajax combo 08 Oct 2012 07:26 #4325

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
I'm not in front of the computer as such today so I can't check but to elaborate on my last post, the content for the combo div is almost certainly going to be loaded in a document ready function. Therefore, check in the document.ready to ensure that your selector follows loading the content/options into your combo....

It might also be helpful to add some breaks in console to step through the script if you're still finding it difficult to locate the point of insertion/id you need.

Best of luck

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: Jquery : id, name or else, for an ajax combo 08 Oct 2012 19:13 #4336

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
Kind of got it to work : i know have the id displayed in my div.
That's already a big step ahead, thanks.
Know i must figure out another thing : how to do a query to get the "machine_name" and not its id...

Just to let you know, i had to change the view.html.php file associated with the view of the "machines" table, where there is a
$event = 	'jQuery("#jform_machine").val(this.value);';
That i modified with
				$event = 
				'
				jQuery("#jform_machine").val(this.value);
				var machine = "";
				machine = jQuery("#jform_machine").val();
				jQuery("#machine").html(machine);
				';
with #machine being the div displaying the actual result in the view
Last Edit: 08 Oct 2012 19:16 by VeCrea.
The administrator has disabled public write access.
Time to create page: 0.154 seconds

Get Started