Link to home
Start Free TrialLog in
Avatar of error77
error77

asked on

Javascript replicate existing button click in link

Hi all,

I am using JQuery Mobile DateBox plugin and it works fine.

It has a button that opens a popup which shows the calendar.

I need to create a link that will do the same thing as it's button.

Does anyone have any idea on how to do this please?

Here is a link to the demo page

http://dev.jtsage.com/jQM-DateBox/

Thanks
Avatar of Vampireofdarkness
Vampireofdarkness
Flag of United Kingdom of Great Britain and Northern Ireland image

Line 384 of jquery.mobile.datebox.js

		var openbutton = $('<b>Test<\/b>')
			.click(function (e) {
				e.preventDefault();
				if ( !o.disabled ) {
					self.open();					
				}
			})
			.appendTo(focusedEl)
			.css({'vertical-align': 'middle', 'float': 'right'});

Open in new window


Removed: .buttonMarkup({icon: 'grid', iconpos: 'notext', corners:true, shadow:true}) from after .appendTo(focusedEl).

That section inserts the button / icon. Put whatever you want in the $('<b>...<\/b>') part, but it must be a tag (not plain text).
Avatar of error77
error77

ASKER

So, how could I create a link that opens the calendar (does the same as that button) please?

ASKER CERTIFIED SOLUTION
Avatar of Vampireofdarkness
Vampireofdarkness
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of error77

ASKER

Sorry, for not explaining myself properly, what I mean is. Is it possible (without changing the JS file), to add my own extra link in the page that would open that popup too?

You can, but you would need to create a section of javascript anyway. The link's called function references parent objects, meaning the link needs to be contained in the <div> tag that the JS creates. You would need to create a listener, and then create your own link.

Your link MUST BE contained in the <div> that is created. You cannot have a link elsewhere on the page.
Avatar of error77

ASKER

Thanks a lot.