Safe Java/ajax Function?

Is this code ok to use in .tpl (all browsers) for autoclick link. Or, are there a better way?



I had to assign dynamic “test” else it only executes once, and it works with ajax.



{if !$my_var}
{assign var="test" value=$smarty.const.TIME}


{/if}

[quote name='gabbo' timestamp='1397815522' post='181932']

Is this code ok to use in .tpl (all browsers) for autoclick link. Or, are there a better way?



I had to assign dynamic “test” else it only executes once, and it works with ajax.



{if !$my_var}
{assign var="test" value=$smarty.const.TIME}


{/if}


[/quote]



Hi,



We do not see any disadvantages. But if your script should be executed from the ajax answer, please add the “cm-ajax-force” class to the script tag.

[quote name='eComLabs' timestamp='1397817370' post='181934']

Hi,



We do not see any disadvantages. But if your script should be executed from the ajax answer, please add the “cm-ajax-force” class to the script tag.

[/quote]



Thanx.

[quote name='gabbo' timestamp='1397876372' post='181955']

Thanx.

[/quote]



You are welcome. Feel free to contact us.

.

Hi, I came across the same kind of issue and I tried to use your solution . Its still not working.


Â


{include file="buttons/button.tpl" but_id=$but_id but_text=__("recalculate") but_onclick=$but_onclick but_href=$but_href but_target=$but_target but_meta="ty-btn__secondary $but_meta cm-ajax cm-ajax-force cm-submit nu-cart-button" but_role=$but_role }


I've used the "cm-ajax-force" to my script tag but it still works only the first time and when it changes the cart content, its not working.

Â

Is there anything that I did wrong?Â

Â

Â

Earlier post just came out wrong.! This is the updated one.! I'm sorry I couldn't edit the earlier one.!


```php {include file=“buttons/button.tpl” but_id=$but_id but_text=__(“recalculate”) but_onclick=$but_onclick but_href=$but_href but_target=$but_target but_meta=“ty-btn__secondary $but_meta cm-ajax cm-ajax-force cm-submit nu-cart-button” but_role=$but_role }




```

This is the code that I wrote for the update cart tpl page and I want to update the cart with my ajax code.
I've tried to use "cm-ajax-force" to my code and it doesn't seem to work for the second time.

Any suggestions to make my code work ?

Please provide us with more details about the required changes? What theme do you use?

I am trying to update the cart when I change the number of products. I m using native responsive theme that comes with cs cart.



I've managed to make the update cart with cm-ajax class for the “Recalculate” button. Now it works fine with the code that I wrote above only for the first time.



After I get the ajax response, the script doesn't seem to work.!



Any suggestions ?

[quote name='vickythegme' timestamp='1428657539' post='210931']

I am trying to update the cart when I change the number of products. I m using native responsive theme that comes with cs cart.



I've managed to make the update cart with cm-ajax class for the “Recalculate” button. Now it works fine with the code that I wrote above only for the first time.



After I get the ajax response, the script doesn't seem to work.!



Any suggestions ?

[/quote]



This code should be located in the block which is updated by the ajax


```php


```

[quote name='eComLabs' timestamp='1428669685' post='210958']

This code should be located in the block which is updated by the ajax


```php


```

[/quote]









I've written the script code with cm-ajax-force just after the “recalculate” button that is used to calculate the cart total item values. Still its not working.!

Try to put the code to the following wrapper:


```php




```

And do not forget to clear the cache

[quote name='eComLabs' timestamp='1428672050' post='210965']

Try to put the code to the following wrapper:


```php




```

And do not forget to clear the cache
[/quote]


Awesome..!! That worked perfectly.. Earlier I had put the code just after "recalculate" button. Then I changed it to cart_items.tpl file and its working fine,

Thanks @ecomLabs.. You made my day. Cheers

You are welcome! Have a nice weekend!

Hi @eComLabs,



I was working on scroll option instead of pagination for categories page.



The code/script that I wrote in view.tpl file works fine at the first time and then I change it to a different layout and then get back to the grid layout, it shows some “Unexpected end of input” and the error points out on the script code that I wrote for the scroll products.