CodeIgniter Forums

Full Version: Calling function using anchor and xajax
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]pawan123[/eluser]
Hi ,

I want to call function using anchor

currently we have anchor("methodName", "Click here")

Here "methodName" is assigned to href bydefault. Instead of this I want to assign it to the onclick event.

I donot want to use "<a href="#">Click here</a>"
Please inspect "Click here" to get what I do not wish to Use.(Selected in blue back-color.)

Just by using anchor is it possible?

Thanks in advance.

El Forum

[eluser]crwtrue[/eluser]
If i understanded correctly you could try somethink like this:

$js = 'onClick="xajax_method_name(); return true;"';

echo anchor('controller/index','Click here',$js);

El Forum

[eluser]pawan123[/eluser]
Thanks for your fast reply,

this is working. I have one more query. Instead calling URL 'Controller/index' I want to put # or javascrpt:void(0);

Thank you ..

El Forum

[eluser]crwtrue[/eluser]
im not sure. you have probably tryed this allready:

$url = 'javascrpt:void(0);';

echo anchor($url,‘Click here’,$js);

El Forum

[eluser]pawan123[/eluser]
thanks for the reply.

It takes the site url bydefault and appends the "first segment" to it.

I have made changes in CI helper file to get the result.