Prototype.js can't save attribute in magento - prototypejs

I have this problem with Magento 1.7, I can't save attributes, the button turns gray and nothing happens.
In firebug, I get this error message
TypeError: value.gsub is not a function
value = value.gsub(/(\r)?\n/, '\r\n');
in prototype.js on line 5809

It looks like you are trying to serialize the elements in a form and one or more of the elements do not have a value attribute to read.
2 ways to fix - either check all your form elements and make sure they have a value='' attribute at the minimum.
OR
you can update the prototype.js file with some of the latest updates which has added checks to make sure the a value attribute exists before trying to act on it.
https://github.com/jwestbrook/prototype/tree/master-w-updates/dist

Related

Triggering Ajax onchange on a select list

I am working on a Drupal project which is using the Editable fields module.
Using that module I'm exposing a dropdown list of text options. It works just great. You click on the list, select an option and the option is updated via Ajax.
My challenge is I'm trying to change the options programmatically via jQuery. Using the following code:
jQuery('select#edit-field-status-0-field-status-und').val(1);
... my browser console area is happy with the code but the Ajax update does not take place.
I tried:
jQuery('select#edit-field-status-0-field-status-und').val(1).change();
Again no errors but the Ajax event still did not execute.
$('#edit-field-status-0-field-status-und').val("1");
will do the trick, as the only reason it wouldn't work would be that you have your select values as strings instead of numbers.
Alternatively the following is more detailed:
$('#edit-field-status-0-field-status-und option').eq(1).prop('selected', true);
Also this is not an 'AJAX' function, it's simply Jquery updating the DOM for the particular element.
The code I was using as recreated below was correct:
jQuery('select#edit-field-status-0-field-status-und').val(1).change();
I found out the reason why it wasn't working was because the ID of the target element changed dynamically.
So when I first inspected and found edit-field-status-0-field-status-und, the same element would change IDs to something like edit-field-status-0-field-status-und--1.
That was throwing things off and gave the impression my code wasn't working.
Thanks to #gts for your input.

In prototype.js in magento on line 1931 when we see it on firebug

I am facing element.style.display = 'none'; this error in prototype.js in line 1931 in magento 1.7
someone please shortout this problem as soon as problems.
That line number is referring to the hide() method. However I think you are using an older version of PrototypeJS as this line is at a different line number in the current version (1.7.1).
Regardless most likely you are trying to run the hide() method on an element that does not exist in your current DOM.
For Instance
$('missingid').hide();
//There is no element on the page with the id "missingid" so this will fail
Double check the id you are trying to hide as well as check the version of PrototypeJS that you have loaded.

kendoui validation tooltip in custom popup editor not positioning correctly

Please see jsfiddle for example, blank out First Name field to have validation tooltip show. In a normal form the validation tooltip positions correctly to the right of each element. But in the popup editor for the grid it still trying to position the tooltip below the element as if it where editing inline. I have tried <span class="k-invalid-msg" data-for="FirstName"></span>but it doesn't change anything. Is there a setting I am missing to get this working in popupeditor? I guess I could manually modify the .k-tooltip but I am hoping for something more built in that handles the positioning correctly, because I am not very good at css.
As you've discovered, the error template for the grid is different to that provided by the kendo validator when applied to standard inputs.
Unfortunately, the validator that is created internally by the grid does not pass along any errorTemplate that you might define in the options object and by the time the "edit" event fires, the validator has already been created and the error template compiled, hence why setting the errorTemplate in the manner you describe does not work. Really, I think the Kendo grid should respect any user defined errorTemplate option but until it does we have to hack a little bit.
The key is to define a custom template and to apply it in the edit event, but instead of using the options object, set the private instance directly. Not ideal, but it works:
edit: function (e) {
e.sender.editable.validatable._errorTemplate =
kendo.template($('#tooltip-template').html());
}
See this updated fiddle for an example of what I think you might be looking to achieve.
http://jsfiddle.net/nukefusion/eQ2j7/10/
(I would post this as a comment but not enough reputation yet...)
I'm successfully using nukefusion's solution. I, too, fought with the syntax error from jQuery for a long time and discovered through debugging that how you define the template is important. In particular, it appears that the template has to be written on a single line without any formatting, as in:
<script id="tooltip-template" type="text/x-kendo-template"><span class="k-widget k-tooltip k-tooltip-validation"><span class="k-icon k-warning"></span>#=message#</span></script>
If you try to make it "pretty" and format the html in the template, you get the syntax error. I don't know where the real bug is, as this sort of thing shouldn't cause an error. But it does and I stopped worrying about it once I got it to work correctly.

mColorPicker error 'Invalid Property value' in IE7

I have recently downloaded mColorPicker.js from here
However, I am running into some issue with this -
When user enters an invalid color value like '#454545xxxx' in the color box, I get a js error - Invalid Property value in IE7 (working fine in Firefox)
error is coming in
jquery-1.4.2.min.js,
line 116 - if(e)f[b]=d
when d = "#454545xxxx"
Also, ColorPicker image is hidden for this textbox.
Any ideas?
The reason this is happening is that the plugin is trying to set the value of the background colour to exactly what the user typed, without doing any validation checking to make sure it is a valid colour. The plugin calls the jQuery .css() method to do this, which is why the error is occurring inside jquery-1.4.2.min.js.
If you are able to modify the plugin code, you can then add checks to make sure the value entered is a valid colour before proceeding.
You might also suggest adding this feature to the plugin author, or, if you get it working successfully, submitting your updated code to them so they can benefit from your work.
I had a quick look, but I don't have the time to properly make the necessary changes to the plugin to ensure it correctly validates the colour is valid in all the right places. Good luck!

bundle product shows price as 0

I've been reading a lot about this problem but I get nothing that suggests a way out.
I am working with version 1.3.2.4 and after creating a bundle product, Magento displays it as price as zero, but gives the "current composition" as the correct value.
alt text http://www.balexandre.com/temp/2009-10-13_2158.png
I already tried to refresh the cache, rebuild the catalog index, and nothing works...
Then I went deep and navigated into the price.phtml template under
template/bundle/catalog/product/view/
and tried to invoke the same method that is showing correctly the value, bu that as well, return zero.
I did notice that Magento has this javascript method
bundle.reloadPrice();
right after and if invoked I do get the correct price... I can try, using jQuery (or Prototype as Magento uses by default) change the value, but I was trying to this right...
Any other ideas?
Had the same problem.
price showed as 0.00.
you have to edit your price-attribute -> show in product-listing: yes
for the product page I'm using this as a work around:
executing this jQuery code:
// hide "Price as configured" text
jQuery(".price-as-configured span:first").hide();
// hide the 0,00 price
jQuery(".price-box-bundle").hide();
// hide the 2nd price (not in image)
jQuery(".product-options-bottom .price-box").hide();
will pass this:
alt text http://www.balexandre.com/temp/2009-10-13_2338.png
into this:
alt text http://www.balexandre.com/temp/2009-10-13_2339.png
In the product grid list I'm using this code to hide the price/button and add to wish list links
// GRID
jQuery("#products-grid-table .price-box").hide();
jQuery("#products-grid-table .button").hide();
jQuery("#products-grid-table .add-to-links").hide();
// LIST
jQuery("#products-list .price-box").hide();
jQuery("#products-list .button").hide();
jQuery("#products-list .add-to-links").hide();
and it will pass this
alt text http://www.balexandre.com/temp/2009-10-14_0005.png
into this
alt text http://www.balexandre.com/temp/2009-10-14_0006.png
I hope it helps someone ...
you can use my magento module: https://github.com/head82/KH_ExtendedBundlePrice tested with magento 1.7

Resources