Page 1 of 2

Change the css class with the mapping result

Posted: Thu Sep 10, 2015 5:26 pm
by Leonardo Valentin Zeferino

Hi!

I'd like a suggestion.

I need to read a field from database and depending what is the value, I need to load a CSS class in a DIV.

I know read the field from database but I don't know how can I read this value and define the css class.

I'm trying to read the field and change the class with the code bellow in the html file but the if clause isn't working.

code
<script>
if (Apperyio('wishlist_status')&#46;textl() == "55600a7fe4b0f840f328ab8f") {
$( '#product_wishlist_bt' )&#46;removeClass( 'product-bookmark' );
$( '#product_wishlist_bt' )&#46;addClass( 'product-bookmarked' );
}
</script>
/code

Thanks!


Change the css class with the mapping result

Posted: Thu Sep 10, 2015 7:13 pm
by Serhii Kulibaba

Hello,

There are no textl() method. Please use text() instead.


Change the css class with the mapping result

Posted: Thu Sep 10, 2015 7:54 pm
by Leonardo Valentin Zeferino

Sorry, @Sergiy.

I fixed "text()" without success. Same result.


Change the css class with the mapping result

Posted: Fri Sep 11, 2015 7:08 pm
by Serhii Kulibaba

Could you show screenshow with mapping with this JS code?


Change the css class with the mapping result

Posted: Sat Sep 12, 2015 4:10 pm
by Leonardo Valentin Zeferino

Hi Sergiy!

I'm using the screenshow. I'm programming direct in js and html code.

Look my code bellow:

product.js

code
Apperyio&#46;mappings["product_readWishlist_onsuccess_mapping_0"] = {
"homeScreen": "product",
"directions": [

Code: Select all

     { 
         "from_name": "readWishlist", 
         "from_type": "SERVICE_RESPONSE", 

         "to_name": "product", 
         "to_type": "UI", 

         "mappings": [ 

         { 

           "source": "$['body'][0]['_id']", 
           "target": "$['wishlist_status:text']" 

         } 
         ] 
     } 

     ] 
 }; 

/code

product.html

code
<div class="product-rating">
<div class="product-bookmark" name="wishlist_bt" id="product_wishlist_bt" dsid="wishlist_bt">
<a href="#">
<i class="zmdi zmdi-bookmark"></i>
</a>
<><!-- /&#46;product-bookmark -->
<script>
if (Apperyio('wishlist_status')&#46;text() == "55600a7fe4b0f840f328ab8f") {
$( '#product_wishlist_bt' )&#46;removeClass( 'product-bookmark' );
$( '#product_wishlist_bt' )&#46;addClass( 'product-bookmarked' );
console&#46;log("bookmarked");
}
</script>
/code


Change the css class with the mapping result

Posted: Tue Sep 15, 2015 12:56 pm
by Serhii Kulibaba

Does this code execute? Could you move it to the JS file instead of HTML component


Change the css class with the mapping result

Posted: Tue Sep 15, 2015 2:56 pm
by Leonardo Valentin Zeferino

Hi Sergiy!

The code executes. But not the if clause because I can't read the text/value of "whishlist_status" label/variable. I show it in the page but I can't use it in my code.

I tried too Apperyio('wishlist_status').val() because I'm comparing with an ID but without success.


Change the css class with the mapping result

Posted: Wed Sep 16, 2015 12:11 pm
by Serhii Kulibaba

Is it ("wishlist_status") Appery.io label component? Could you show us screenshot with it?
Could you clarify have you changed anything on Source tab? This (http://devcenter.appery.io/tutorials/...) doc should help.


Change the css class with the mapping result

Posted: Wed Sep 16, 2015 2:47 pm
by Leonardo Valentin Zeferino

Hi Sergiy!

6 days and you didn't understand my problem yet.

I'm programming directly in source tab and there isn't any possibility to not use the source tab. Suggestions like "make refresh" in source code isn't an option. I need to program directly in source code because my layout is customized.

Yes, "wishlist_status" is a Appery.io label component.
I just want to get the value of this component and use it in a javascript code.


Change the css class with the mapping result

Posted: Thu Sep 17, 2015 1:52 pm
by Serhii Kulibaba

If you change source code - you get your custom code. We are very sorry, but this is something outside the scope: http://devcenter.appery.io/support-po... of our support.